Android 平板上 同时显示多个进度框 正在加载中

      因为最近做的是平板的项目,由于尺寸很大,所以一个界面上需要同时加载多个界面,而这多个界面又是从服务器拿数据的,耗时比较久,所以需要使用到圆形的进度条,一开始是使用系统的进度条,然后后台执行线程拿数据,但是弹出系统的进度框,就会使背景无法点击,而且变暗,这不符合需求,需要在每个获取的部分区域,加载一个进度框,其他部分可以点击,搜了一下使用原生的进度框无法实现这样的功能,看来只能自定义了,找到一位前辈写的使用动画效果做的view的例子,连接如下:

正在加载中 这位博主的实现原理是选择一张带有圆形的图片,当数据加载完,隐藏相应的布局就可以了,在他的基础上,我修改了一点,基本上是这个意思,如下代码:

/**
	 * 
	 * @Title: loadNowProsss
	 * @Description: 数据加載中,彈出自定義的view,以便於同時顯示4個對話框
	 * @param 
	 * @return void
	 * @throws  
	 */
	public void loadNowProsssSecondCycle() {
		// 加载动画
		Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this,
				R.anim.animation);
		// 使用ImageView显示动画
		chart_second_imagecycle.startAnimation(hyperspaceJumpAnimation);

		new Thread() {
			@Override
			public void run() {
				try {
					//加载数据,耗时操作

				} finally {
					Runnable work = new Runnable() {

						@Override
						public void run() {
                                                        //获取对话框的布局id,以便于隐藏掉进度框
							chart_second_dialogview.setVisibility(View.GONE);
						}
					};
					handler.post(work);
				}
			}
		}.start();
	}
对话框的布局文件如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/chart_second_dialogview"
    android:layout_width="180dip"
    android:layout_height="60dp"
    android:layout_alignParentTop="true"
    android:layout_marginTop="85dp"
    android:layout_marginBottom="45dp"
    android:layout_marginLeft="75dp"
    android:layout_marginRight="25dp"
    android:background="@drawable/allboard"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/chart_second_imagecycle"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_marginLeft="20dp"
        android:padding="2dip"
        android:src="@drawable/waiting_up" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/chart_second_imagecycle"
        android:gravity="center"
        android:text="@string/dialogchart_text"
        android:textSize="16sp" />

</RelativeLayout>

给弹出的view周围加上边框,如下allboard.xml:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- 连框颜色值 -->
    <item>
        <shape>
            <solid android:color="#000000" />

            <stroke
                android:width="0.1dp"
                android:color="#ffa8abad" />
        </shape>
    </item>

</layer-list>



这样就可以避免使用系统的,也不用自定义一些控件就可以实现,有问题可以探讨。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值