Android使用Shape實(shí)現(xiàn)ProgressBar樣式實(shí)例
使用Shape實(shí)現(xiàn)樣式
使用Shape中的ring實(shí)現(xiàn),如下布局ring.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:thickness="5dp"
android:useLevel="false" >
<gradient
android:endColor="#888"
android:startColor="#ccc"
android:type="sweep"
android:useLevel="false" />
</shape>
使用rotate使之旋轉(zhuǎn)
如下progressbar.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/ring"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080"/>
</item>
</layer-list>
注意:其中fromDegrees與toDegrees之差要是360的倍數(shù),不然中間會(huì)有轉(zhuǎn)的時(shí)候會(huì)跳一下,另外,這個(gè)差越大就轉(zhuǎn)得越快,具體效果大家可以自行試一下
使用
<ProgressBar style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminateDrawable="@drawable/progressbar" <!-- 這里使用自定義的progressbar樣式 --> />
更簡單的方法
直接使用一個(gè)布局文件就可以實(shí)現(xiàn):
<?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="1080" >
<shape
android:shape="ring"
android:thickness="5dp"
android:useLevel="false" >
<gradient
android:endColor="#888"
android:startColor="#ccc"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android編程使用自定義shape實(shí)現(xiàn)shadow陰影效果的方法
- Android自定義shape的使用示例
- Android控件系列之Shape使用方法
- Android中的Shape和Selector的結(jié)合使用實(shí)例
- Android中shape定義控件的使用
- Android shape和selector 結(jié)合使用實(shí)例代碼
- Android開發(fā)教程之shape和selector的結(jié)合使用
- Android中drawable使用Shape資源
- 詳解android shape的使用總結(jié)
- Android利用shape實(shí)現(xiàn)各種簡單的形狀
相關(guān)文章
Android NDK開發(fā)(C語言基本數(shù)據(jù)類型)
這篇文章主要介紹了Android NDK開發(fā)中,C語言基本數(shù)據(jù)類型,主要以C語言包含的數(shù)據(jù)類型及基本類型展開相關(guān)資料,需要的朋友可以參考一下2021-12-12
Android?studio實(shí)現(xiàn)簡單計(jì)算器的編寫
這篇文章主要為大家詳細(xì)介紹了Android?studio實(shí)現(xiàn)簡單計(jì)算器的編寫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05
ExpandableListView實(shí)現(xiàn)二級列表購物車
這篇文章主要為大家詳細(xì)介紹了ExpandableListView實(shí)現(xiàn)二級列表購物車,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11
Android如何在App中啟動(dòng)系統(tǒng)鬧鐘
這篇文章主要為大家詳細(xì)介紹了Android如何在App中啟動(dòng)系統(tǒng)鬧鐘,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01
Android自定義View實(shí)現(xiàn)時(shí)鐘效果
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)時(shí)鐘效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-01-01
Android WaveView實(shí)現(xiàn)水流波動(dòng)效果
這篇文章主要介紹了 Android自定義控件 WaveView實(shí)現(xiàn)水流波動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03
Gradle屬性設(shè)置及環(huán)境變量全面教程
這篇文章主要為大家介紹了Gradle屬性設(shè)置及環(huán)境變量的全面教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06
Android App后臺(tái)服務(wù)報(bào)告工作狀態(tài)實(shí)例
這篇文章主要介紹了Android App后臺(tái)服務(wù)報(bào)告工作狀態(tài)實(shí)例,使用LocalBroadcastManager發(fā)送和接收狀態(tài),需要的朋友可以參考下2014-06-06

