1、要实现的转圈进度条的效果图如下所示:
2、view_loading.xml中代码如下所示:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/loading_view_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#e5e4e9" android:descendantFocusability="blocksDescendants" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:gravity="top" > <ProgressBar android:id="@+id/loading_view_progressbar" style="@style/loadingViewProgressBarStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:visibility="visible" /> <TextView android:id="@+id/loading_view_textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/loading_view_progressbar" android:layout_centerHorizontal="true" android:layout_marginTop="4dp" android:text="正在加载..." android:textColor="#999999" android:textSize="12sp" /> </RelativeLayout> </RelativeLayout>
3、styles.xml中的loadingViewProgressBarStyle如下所示:
<style name="loadingViewProgressBarStyle"> <item name="android:indeterminateDrawable">@drawable/load_rotate</item> <item name="android:minWidth">20dip</item> <item name="android:maxWidth">20dip</item> <item name="android:minHeight">20dip</item> <item name="android:maxHeight">20dip</item> </style>
4、drawable文件夹下load_rotate.xml文件内容如下所示:
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/load_icon" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="360" />
5、load_icon的图片形式如下所示:
时间: 2024-10-11 21:02:58