做项目的时候希望滚动圈出现在中间,在布局文件中,如果使用的线性布局,那么滚动圈出现在左上角,所以应该把LinearLayout改为RelativeLayout:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@color/white"
>
<include android:id="@+id/title" layout="@layout/main_title"/>
<GridView android:id="@+id/gridview" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:numColumns="3"
android:verticalSpacing="2dip" android:horizontalSpacing="2dip"
android:scrollbars="none"
android:gravity="center">
</GridView>
<include android:layout_centerHorizontal="true"
android:layout_centerInParent="true" android:layout_width="wrap_content"
android:visibility="gone" android:layout_height="90dip" layout="@layout/progressbar" />
</RelativeLayout>
include包含外部的progressbar.xml布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ProgessBar_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:padding="5px"
android:background="@drawable/progress_back">
<ProgressBar android:id="@+id/ProgressBar_bar"
style="?android:attr/progressBarStyle" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:indeterminateDrawable="@drawable/draw_progessbar"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="3dip"
android:layout_marginBottom="3dip"
/>
<TextView android:id="@+id/ProgressBar_txt" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="正在加载中,请稍候..."
android:lines="2"
android:layout_marginTop="3dip"
android:layout_marginBottom="3dip"
android:layout_below="@id/ProgressBar_bar"/>
</RelativeLayout>
在Activity里面使用滚动圈,private View progressBarView;
在onCreate方法里写progressBarView = findViewById(R.id.ProgessBar_layout);
progressBarView.setVisibility(View.VISIBLE);
最后在获取完数据之后把滚动圈隐藏,
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
switch (msg.what) {
case DATA_SUCCESS:
listViewAdater.notifyDataSetChanged();
progressBarView.setVisibility(View.INVISIBLE);
分享到:
相关推荐
由于最近项目需要根据系统的风格自定义progressbar,所以对此学习了。也整理了一个小的demo.主要是修改默认的背景,加上自己喜欢的背景,以及在圆圈中间显示加载百分比。主要是用来加载图片用的。
ProgressBar使用图片是圆角demo,仅供参考
C#下ProgressBar详细使用方法
使用了handler消息机制,显示进度条中进度和数值的变化。
使用ProgressBar实现垂直温度计效果,可以自行美化控件
1)进度条ProgressBar使用方法 1、在layout布局文件中创建ProgressBar控件 <ProgressBar nstyle=?android:attr/progressBarStyleHorizontal android:layout_width match_parent android:layout_height=wrap_content...
带动画的横向ProgressBar
NULL 博文链接:https://android-zhang.iteye.com/blog/1611330
这个demo主要讲解了Progressbar的使用,希望可以帮助需要的同学.
主要是使用了ImageView和AnimationDrawable组合的方式来实现ProgressBar的旋转效果
Android应用源码之ProgressBar 几乎全部的用法
Android中使用ProgressBar实现进度条,详细了解请移步:http://blog.csdn.net/zxc514257857/article/details/70557872
纯Java代码创建ProgressBar,不使用xml布局文件,代码解读http://blog.csdn.net/codehxy/article/details/30744439
Android下ProgressBar和旗下两个子控件的使用,具体可参见博客http://www.cnblogs.com/plokmju/p/android_ProgressBar.html
progressbar加音量控制
赠送jar包:progressbar-0.5.5.jar; 赠送原API文档:progressbar-0.5.5-javadoc.jar; 赠送源代码:progressbar-0.5.5-sources.jar; 赠送Maven依赖信息文件:progressbar-0.5.5.pom; 包含翻译后的API文档:...
从网上整理的c# ProgressBar 光滑进度条的源码,呵呵,大家看看吧~vc#2005的~
另外启动一个线程,在此线程中用this.Dispatcher.Invoke方法改变ProgressBar的Value
android progressbar 垂直布局