日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android圆形进度条ProgressBar颜色设置

發(fā)布時(shí)間:2024/4/17 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android圆形进度条ProgressBar颜色设置 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原帖地址:http://www.apkbus.com/android-19012-1-1.html
xml布局文件需加入如下的進(jìn)度條構(gòu)件:
Java代碼
  • <ProgressBar
  • ? ?? ???android:id="@+id/loadProgressBar"
  • ? ?? ???android:layout_width="wrap_content"
  • ? ?? ???android:layout_height="wrap_content"
  • ? ?? ???android:indeterminateDrawable="@drawable/progressbar" />
  • 復(fù)制代碼 其中的indeterminteDrawable屬性就是用來設(shè)置進(jìn)度條顏色等屬性的,其內(nèi)容如下:
    Java代碼
  • <?xml version="1.0" encoding="utf-8"?>
  • <rotate xmlns:android="http://schemas.android.com/apk/res/android"
  • ? ? android:fromDegrees="0"
  • ? ? android:pivotX="50%"
  • ? ? android:pivotY="50%"
  • ? ? android:toDegrees="360" >

  • ? ? <shape
  • ? ?? ???android:innerRadiusRatio="3"
  • ? ?? ???android:shape="ring"
  • ? ?? ???android:thicknessRatio="8"
  • ? ?? ???android:useLevel="false" >

  • ? ?? ???<gradient
  • ? ?? ?? ?? ?android:centerColor="#FFFFFF"
  • ? ?? ?? ?? ?android:centerY="0.50"
  • ? ?? ?? ?? ?android:endColor="#FFFF00"
  • ? ?? ?? ?? ?android:startColor="#000000"
  • ? ?? ?? ?? ?android:type="sweep"
  • ? ?? ?? ?? ?android:useLevel="false" />
  • ? ? </shape>

  • </rotate>
  • 復(fù)制代碼 三種方式實(shí)現(xiàn)自定義圓形頁面加載中效果的進(jìn)度條:
    來自:http://407827531.iteye.com/blog/1067025

    默認(rèn)情況下Indeterminate Progressbar是白色的,如果容器的背景也是白色的,這樣就根本看不到Progressbar了。

    幸好Android自帶了一些反轉(zhuǎn)樣式,你可以采用其中一個(gè)合適的:
    Java代碼
  • <ProgressBar style="@android:style/Widget.ProgressBar.Inverse"/>
  • <ProgressBar style="@android:style/Widget.ProgressBar.Large.Inverse"/>
  • <ProgressBar style="@android:style/Widget.ProgressBar.Small.Inverse"/>
  • 復(fù)制代碼 進(jìn)度條:

    Java代碼
  • <ProgressBar
  • ? ?? ???style="?android:attr/progressBarStyleHorizontal"
  • ? ?? ???android:layout_width="fill_parent"
  • ? ?? ???android:layout_height="wrap_content" />
  • <ProgressBar
  • ? ?? ???android:id="@+id/circleProgressBar"
  • ? ?? ???style="?android:attr/progressBarStyleLarge"
  • ? ?? ???android:layout_width="wrap_content"
  • ? ?? ???android:layout_height="wrap_content"
  • ? ?? ???mce_style="?android:attr/progressBarStyleLarge" />
  • 復(fù)制代碼 一、通過動(dòng)畫實(shí)現(xiàn)
    定義res/anim/loading.xml如下:
    Java代碼
  • <?xml version="1.0" encoding="UTF-8"?>
  • <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
  • ? ? android:oneshot="false" >

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_01"
  • ? ?? ???android:duration="150"/>

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_02"
  • ? ?? ???android:duration="150"/>

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_03"
  • ? ?? ???android:duration="150"/>

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_04"
  • ? ?? ???android:duration="150"/>

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_05"
  • ? ?? ???android:duration="150"/>

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_06"
  • ? ?? ???android:duration="150"/>

  • ? ? <item
  • ? ?? ???android:drawable="@drawable/loading_07"
  • ? ?? ???android:duration="150"/>

  • </animation-list>
  • 復(fù)制代碼 在layout文件中引用如下:
    Java代碼
  • <ProgressBar
  • ? ?? ???android:id="@+id/loading_process_dialog_progressBar"
  • ? ?? ???android:layout_width="wrap_content"
  • ? ?? ???android:layout_height="wrap_content"
  • ? ?? ???android:indeterminate="false"
  • ? ?? ???android:indeterminateDrawable="@anim/loading" />
  • 復(fù)制代碼 二、通過自定義顏色實(shí)現(xiàn)
    定義res/drawable/dialog_style_xml_color.xml如下:
    Java代碼
  • <?xml version="1.0" encoding="utf-8"?>
  • <rotate xmlns:android="http://schemas.android.com/apk/res/android"
  • ? ? android:fromDegrees="0"
  • ? ? android:pivotX="50%"
  • ? ? android:pivotY="50%"
  • ? ? android:toDegrees="360" >

  • ? ? <shape
  • ? ?? ???android:innerRadiusRatio="3"
  • ? ?? ???android:shape="ring"
  • ? ?? ???android:thicknessRatio="8"
  • ? ?? ???android:useLevel="false" >

  • ? ?? ???<gradient
  • ? ?? ?? ?? ?android:centerColor="#FFDC35"
  • ? ?? ?? ?? ?android:centerY="0.50"
  • ? ?? ?? ?? ?android:endColor="#CE0000"
  • ? ?? ?? ?? ?android:startColor="#FFFFFF"
  • ? ?? ?? ?? ?android:type="sweep"
  • ? ?? ?? ?? ?android:useLevel="false" />
  • ? ? </shape>

  • </rotate>
  • 復(fù)制代碼 在layout文件中引用如下:
    Java代碼
  • <ProgressBar
  • ? ?? ???android:id="@+id/loading_process_dialog_progressBar"
  • ? ?? ???android:layout_width="wrap_content"
  • ? ?? ???android:layout_height="wrap_content"
  • ? ?? ???android:indeterminate="false"
  • ? ?? ???android:indeterminateDrawable="@drawable/dialog_style_xml_color" />
  • 復(fù)制代碼 三、使用一張圖片進(jìn)行自定義
    定義res/drawable/dialog_style_xml_icon.xml如下:
    Java代碼
  • <?xml version="1.0" encoding="utf-8"?>
  • <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

  • ? ? <item>
  • ? ?? ???<rotate
  • ? ?? ?? ?? ?android:drawable="@drawable/dialog_progress_round"
  • ? ?? ?? ?? ?android:fromDegrees="0.0"
  • ? ?? ?? ?? ?android:pivotX="50.0%"
  • ? ?? ?? ?? ?android:pivotY="50.0%"
  • ? ?? ?? ?? ?android:toDegrees="360.0" />
  • ? ? </item>

  • </layer-list>
  • 復(fù)制代碼 在layout文件中引用如下:
    Java代碼
  • <ProgressBar
  • ? ?? ???android:id="@+id/loading_process_dialog_progressBar"
  • ? ?? ???android:layout_width="wrap_content"
  • ? ?? ???android:layout_height="wrap_content"
  • ? ?? ???android:indeterminate="false"
  • ? ?? ???android:indeterminateDrawable="@drawable/dialog_style_xml_icon" />
  • 復(fù)制代碼 或者
    Java代碼
  • <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  • ? ?<item android:id="@android:id/background">? ?
  • ? ? <shape>? ?
  • ? ?? ???<corners android:radius="5dip" />? ?
  • ? ?? ???<gradient android:startColor="#ff9d9e9d"? ?
  • ? ?? ?? ?? ? android:centerColor="#ff5a5d5a"? ?
  • ? ?? ?? ?? ? android:centerY="0.75"? ?
  • ? ?? ?? ?? ? android:endColor="#ff747674"? ?
  • ? ?? ?? ?? ? android:angle="270"? ?
  • ? ?? ?? ?? ? />? ?
  • ? ? </shape>? ?
  • </item>? ?
  • <item android:id="@android:id/secondaryProgress">? ?
  • ? ? <clip>? ?
  • ? ?? ???<shape>? ?
  • ? ?? ?? ?? ?<corners android:radius="5dip" />? ?
  • ? ?? ?? ?? ?<gradient android:startColor="#80ffd300"? ?
  • ? ?? ?? ?? ?? ???android:centerColor="#80ffb600"? ?
  • ? ?? ?? ?? ?? ???android:centerY="0.75"? ?
  • ? ?? ?? ?? ?? ???android:endColor="#a0ffcb00"? ?
  • ? ?? ?? ?? ?? ???android:angle="270"? ?
  • ? ?? ?? ?? ?? ? />? ?
  • ? ?? ???</shape>? ?
  • ? ? </clip>? ?
  • </item>? ?
  • <item android:id="@android:id/progress">? ?
  • ? ? <clip>? ?
  • ? ?? ???<shape>? ?
  • ? ?? ?? ?? ?<corners android:radius="5dip" />? ?
  • ? ?? ?? ?? ?<gradient android:startColor="@color/progress_start"? ?
  • ? ?? ?? ?? ?? ? android:endColor="@color/progress_end"? ?
  • ? ?? ?? ?? ?? ? android:angle="270" />? ?
  • ? ?? ???</shape>? ?
  • ? ? </clip>? ?
  • </item>
  • </layer-list>
  • 復(fù)制代碼 代碼中設(shè)置:
    Java代碼
  • mProgress = (ProgressBar) findViewById(R.id.progress_bar);
  • ? ? ? ? ? ? ? ? Drawable d = this.getResources().getDrawable(R.drawable.my_progress);
  • ? ? ? ? ? ? ? ? mProgress.setProgressDrawable(d);
  • 復(fù)制代碼








    總結(jié)

    以上是生活随笔為你收集整理的android圆形进度条ProgressBar颜色设置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。