自定义进度条样式progressBar

页面调用:

Drawable draw = context.getResources().getDrawable(R.drawable.progress_gq_new);
mHolder. food_progressBar.setProgressDrawable( draw);mHolder. food_progressBar.setProgress(shelfmillon);
布局文件:

<ProgressBar
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="@dimen/dp_65"
    android:layout_height="@dimen/dp_10"
    android:id="@+id/food_progressBar"
    android:layout_marginTop="@dimen/dp_8"
    android:maxHeight="4dp"
    android:minHeight="4dp"
    android:layout_below="@+id/item_foodimag"
    android:layout_centerHorizontal="true" />


progress_gq_new.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"  android:drawable="@drawable/food_fresh_bg">
    item>

    
    <item  android:id="@android:id/progress" >
        <clip android:drawable="@drawable/food_fresh_gq">
        clip>
    item>


layer-list>
或者(样式)
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="10dip" />

            

            <solid android:color="#797979"/>
        shape>
    item>

    
    <item  android:id="@android:id/progress" >
        <clip>
            <shape>
                <corners android:radius="6dp" />
                <gradient  android:startColor="#dd7e0d"
                    android:endColor="#dd7e0d" />
            shape>
        clip>
    item>


layer-list>






你可能感兴趣的:(android学习,视频,图像,音乐,效果)