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:andro>
    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:andro>
    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>

 

运行效果:

Android中使用shape制作一个旋转的progressbar

相关文章:

  • 2021-10-05
  • 2021-11-20
  • 2022-12-23
  • 2021-09-11
  • 2021-05-31
  • 2021-11-28
猜你喜欢
  • 2022-01-18
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
相关资源
相似解决方案