public class ZNtestResActivity
extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_progress);
}
}
detail_progress布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/detail_progress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center" >
<
ProgressBar
style="@style/progress_bar_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5.0dip"
android:text="@string/data_loading"
android:textColor="@color/text_gray"
android:textSize="16.0dip" />
</LinearLayout>
样式文件文件:
<style name="progress_bar_style" parent="@android:style/Widget.ProgressBar">
<item name="android:indeterminateDrawable">@drawable/progress_bar</item>
</style>
//使用shape定义的progressbar的效果文件
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0.0"
android:pivotX="50.0%"
android:pivotY="50.0%"
android:toDegrees="360.0" >
<
shape
android:innerRadiusRatio="3.0"
android:shape="ring"
android:thicknessRatio="8.0"
android:useLevel="false" >
<
gradient
android:centerColor="#ffffffff"
android:centerY="0.5"
android:endColor="#ff000000"
android:startColor="#ff000000"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
运行效果:
转载于:https://www.cnblogs.com/tianshidechibang234/p/3322508.html