Android自定義View實(shí)現(xiàn)投票進(jìn)度條
本文實(shí)例為大家分享了Android投票進(jìn)度條的具體代碼,供大家參考,具體內(nèi)容如下
效果展示




功能屬性介紹
<!-- MatchSupportProgressBar --> <declare-styleable name="MatchSupportProgressBar"> <!-- 進(jìn)度條圓角角度 --> <attr name="progress_radio" format="string"></attr> <!-- 進(jìn)度條左側(cè)Tag文本 --> <attr name="progress_tag_text" format="string"></attr> <!-- 進(jìn)度條已填充部分顏色 --> <attr name="progress_reach_color" format="color"></attr> <!-- 進(jìn)度條已填充部分高度 --> <attr name="progress_reach_height" format="dimension"></attr> <!-- 進(jìn)度條背景顏色 --> <attr name="progress_background_color" format="color"></attr> <!-- 進(jìn)度條背景高度 --> <attr name="progress_background_height" format="dimension"></attr> <!-- 進(jìn)度條左側(cè)Tag文本顏色 --> <attr name="progress_tag_text_color" format="color"></attr> <!-- 進(jìn)度條左側(cè)Tag文本尺寸 --> <attr name="progress_tag_text_size" format="dimension"></attr> <!-- 進(jìn)度條右側(cè)百分比文本顏色 --> <attr name="progress_percent_text_color" format="color"></attr> <!-- 進(jìn)度條右側(cè)百分比文本尺寸 --> <attr name="progress_percent_text_size" format="dimension"></attr> <!-- 進(jìn)度條右側(cè)百分比文本 --> <attr name="progress_percent_text" format="string"></attr> <!-- 進(jìn)度條選中的圖標(biāo)與進(jìn)度條、文字的間距 --> <attr name="progress_offsetX" format="dimension"></attr> <!-- 進(jìn)度條右側(cè)文字的水平偏移量 --> <attr name="progress_offsetR" format="dimension"></attr> <!-- 進(jìn)度條之間的偏移量 --> <attr name="progress_LineSpacing" format="dimension"></attr> </declare-styleable>
xml使用示例
<com.yjyc.supportprogress.view.MatchSupportProgressBar android:id="@+id/progressbar_match_support" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:paddingLeft="3dp" android:paddingRight="3dp" android:progress="30" yjcp:progress_background_color="#333" yjcp:progress_background_height="30dp" yjcp:progress_offsetR="20dp" yjcp:progress_percent_text_color="#345698" yjcp:progress_percent_text_size="13sp" yjcp:progress_reach_color="#999" yjcp:progress_tag_text_color="#ffffff" yjcp:progress_tag_text="杰倫;那英;汪峰" yjcp:progress_tag_text_size="13sp" />
java使用示例
//進(jìn)度條的點(diǎn)擊事件監(jiān)聽(tīng)
mspb.setOnRightTextClickListener(new OnRightTextClickListener() {
@Override
public void onClick(int position) {
//position是點(diǎn)擊的位置
}
});
/*
為進(jìn)度條賦值:
參數(shù)1:是我們算好的進(jìn)度值,一般由服務(wù)器返回。(注: yjcp:progress_tag_text="杰倫;那英;汪峰"設(shè)置 了幾個(gè)字符串,getPercentList就要傳幾個(gè)字符串)
參數(shù)2:得到一個(gè)boolean類型的集合,用于設(shè)置進(jìn)度條√顯示的位置
參數(shù)3:true表示已投票,false表示未投票
參數(shù)4:是否開(kāi)啟動(dòng)畫(huà)特效
*/
mspb.setPercentState(getPercentList("10","90","100"), getCheckList(position), true, true);
//重置進(jìn)度條狀態(tài),如果在listview中涉及到復(fù)用問(wèn)題條用它即可。 //參數(shù):true投過(guò)票,false未投過(guò) mspb.setState(false);
源碼下載:Android投票進(jìn)度條
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
mui.init()與mui.plusReady()區(qū)別和關(guān)系
給大家分享一下在使用MUI進(jìn)行APP開(kāi)發(fā)的時(shí)候,mui.init()與mui.plusReady()區(qū)別以及使用上不同之處。2017-11-11
Android實(shí)現(xiàn)上傳文件到服務(wù)器實(shí)例詳解
本篇文章詳細(xì)介紹了Android實(shí)現(xiàn)上傳文件到服務(wù)器實(shí)例詳解,實(shí)現(xiàn)了文件每隔5秒進(jìn)行上傳,有需要的可以了解一下。2016-11-11
PopupWindow自定義位置顯示的實(shí)現(xiàn)代碼
這篇文章主要為大家詳細(xì)介紹了PopupWindow自定義位置顯示,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
Android開(kāi)發(fā)利器之pidcat安裝方式
pidcat 是Android屆JakeWharton大神開(kāi)發(fā)的一款命令行工具,堪稱Android開(kāi)發(fā)利器,它能方便Android程序猿捕獲日志,過(guò)濾日志,定位程序問(wèn)題,超級(jí)好用。這篇文章給大家介紹了Android開(kāi)發(fā)利器之pidcat,需要的朋友可以參考下2019-05-05
Android開(kāi)發(fā)高仿課程表的布局實(shí)例詳解
這篇文章主要介紹了Android開(kāi)發(fā)高仿課程表的布局實(shí)例詳解的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-10-10
Android實(shí)現(xiàn)3D標(biāo)簽云效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)3D標(biāo)簽云效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
Android通過(guò)RemoteViews實(shí)現(xiàn)跨進(jìn)程更新UI示例
本篇文章主要介紹了Android通過(guò)RemoteViews實(shí)現(xiàn)跨進(jìn)程更新UI示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02
Android編程實(shí)現(xiàn)自定義toast示例
這篇文章主要介紹了Android編程實(shí)現(xiàn)自定義toast,結(jié)合簡(jiǎn)單實(shí)例形式分析了自定義布局toast核心實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2017-01-01
Android多媒體應(yīng)用使用SoundPool播放音頻
這篇文章主要為大家詳細(xì)介紹了Android多媒體應(yīng)用使用SoundPool播放音頻,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12

