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

首頁 > 系統 > Android > 正文

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

2019-10-23 19:51:04
字體:
來源:轉載
供稿:網友

先看看效果圖:

Android,view,進度條

首先是布局文件

<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();

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


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平阳县| 渭南市| 开原市| 吉木萨尔县| 石楼县| 扎赉特旗| 西城区| 开封市| 贡山| 建瓯市| 商城县| 桂阳县| 台东县| 鲜城| 青海省| 延寿县| 称多县| 德阳市| 太仆寺旗| 会理县| 张家港市| 涿鹿县| 北碚区| 黄浦区| 安远县| 广水市| 镇康县| 卢龙县| 南陵县| 崇阳县| 新安县| 海丰县| 吉水县| 深泽县| 陇西县| 苍山县| 库车县| 中卫市| 乌兰县| 峨眉山市| 曲松县|