安卓 UI系列之ProgressBar

來源:互聯網
上載者:User

標籤:hid   die   one   src   www   padding   schema   net   pad   

系統預設樣式進度條
/** * Android 七種進度條的樣式 *  http://www.jb51.net/article/71269.htm 七種樣式 *  http://www.cnblogs.com/Yang-jing/p/3757219.html 屬性詳解 */

基於系統進度條自訂樣式

/** * 基於系統自訂樣式的進度條 *  http://www.jb51.net/article/91909.htm 百分比樣式 *  http://www.jb51.net/article/96146.htm 載入樣式 */
    <ProgressBar        android:id="@+id/pb_progressbar"        style="@style/StyleProgressBarMini"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_margin="30dp"        android:background="@drawable/shape_progressbar_bg"        android:max="100"        android:progress="50" />
values/styles.xml
    <style name="StyleProgressBarMini" parent="@android:style/Widget.ProgressBar.Horizontal">        <item name="android:maxHeight">50dip</item>        <item name="android:minHeight">10dip</item>        <item name="android:indeterminateOnly">false</item>        <item name="android:indeterminateDrawable">            @android:drawable/progress_indeterminate_horizontal        </item>        <item name="android:progressDrawable">@drawable/shape_progressbar_mini</item>    </style>
View Code
drawable/shape_progressbar_bg.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">    <solid android:color="#cecece" />    <corners android:radius="90dp" />    <padding        android:bottom="1dp"        android:left="1dp"        android:right="1dp"        android:top="1dp" /></shape>
View Code
drawable/shape_progressbar_mini.xml
<?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="#FFFFFF"                android:startColor="#FFFFFF" />        </shape>    </item>    <item android:id="@android:id/secondaryProgress">        <clip>            <shape>                <corners android:radius="0dip" />                <gradient                    android:angle="270"                    android:centerY="0.75"                    android:endColor="#df0024"                    android:startColor="#df0024" />            </shape>        </clip>    </item>    <item android:id="@android:id/progress">        <clip>            <shape>                <corners android:radius="5dip" />                <gradient                    android:angle="270"                    android:centerY="0.75"                    android:endColor="#0c07ff"                    android:startColor="#33fd00" />            </shape>        </clip>    </item></layer-list>
View Code


百分比進度條



/** * 自訂進度條樣式樣本3 *  參考項目: *      https://github.com/hongyangAndroid/Android-ProgressBarWidthNumber */

 

安卓 UI系列之ProgressBar

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.