国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android自定義view實現進度條指示效果

2019-12-12 03:55:28
字體:
來源:轉載
供稿:網友

先看看效果圖:

首先是布局文件

<FrameLayout android:layout_width="match_parent" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_height="wrap_content"> <ProgressBar  android:id="@+id/pb_process"  style="@style/ProgressStyle"  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:indeterminate="false" /> <TextView  android:id="@+id/tv_progress"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_gravity="center"  android:textColor="@color/white"/></FrameLayout>

添加style-ProgressStyle

<style name="TrainProgressStyle" parent="@android:style/Widget.ProgressBar.Horizontal"> <item name="android:progressDrawable">@drawable/my_progress</item></style>

添加drawable-my_progress

<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background">  <shape>   <corners android:radius="5dip" />   <gradient    android:angle="270"    android:centerY="0.75"    android:endColor="@color/gray_BB"    android:startColor="@color/gray_BB" />  </shape> </item> <item android:id="@android:id/secondaryProgress">  <clip>   <shape>    <corners android:radius="5dip" />    <gradient     android:angle="270"     android:centerColor="#f69200"     android:centerY="0.75"     android:endColor="#ff9800"     android:startColor="#ff9800" />   </shape>  </clip> </item> <item android:id="@android:id/progress">  <level-list>   <!-- 進度滿時 level = 10000-->   <item    android:maxLevel="10000"    android:minLevel="10000">    <clip>     <shape>      <corners android:radius="5dip" />      <gradient       android:angle="270"       android:centerColor="#21a837"       android:centerY="0.75"       android:endColor="#22ac38"       android:startColor="#22ac38" />     </shape>    </clip>   </item>   <!-- 進度未滿時 level < 10000-->   <item    android:minLevel="0"    android:maxLevel="9999"    >    <clip>     <shape>      <corners android:radius="5dip" />      <gradient       android:angle="270"       android:centerColor="#f69200"       android:centerY="0.75"       android:endColor="#ff9800"       android:startColor="#ff9800" />     </shape>    </clip>   </item>  </level-list> </item></layer-list>

activity里的使用和安卓默認的一樣

pb_progress.setMax();pb_progress.setProgress();

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湘潭市| 民勤县| 永新县| 桃园市| 乌兰察布市| 万安县| 博爱县| 吉首市| 绵阳市| 拉萨市| 霍城县| 剑河县| 巩义市| 普陀区| 开远市| 米泉市| 庄河市| 泸州市| 桃园县| 肥西县| 赤壁市| 吴忠市| 东乌珠穆沁旗| 柘城县| 长汀县| 连州市| 吉隆县| 小金县| 花莲市| 沙洋县| 垦利县| 塘沽区| 合川市| 义马市| 阿鲁科尔沁旗| 沈阳市| 巴里| 承德市| 宝应县| 淮北市| 岚皋县|