ProgressBar的使用(注意小细节)
做项目的时候希望滚动圈出现在中间,在布局文件中,如果使用的线性布局,那么滚动圈出现在左上角,所以应该把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>
<?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>