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)文章
Android基于OpenGL的GLSurfaceView創(chuàng)建一個(gè)Activity實(shí)現(xiàn)方法
這篇文章主要介紹了Android基于OpenGL的GLSurfaceView創(chuàng)建一個(gè)Activity實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了Android中OpenGL圖形操作類GLSurfaceView的功能、用法及相關(guān)使用技巧,需要的朋友可以參考下2016-10-10Android實(shí)現(xiàn)密碼明密文切換(小眼睛)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)密碼明密文切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08android 判斷網(wǎng)絡(luò)是否可用與連接的網(wǎng)絡(luò)是否能上網(wǎng)
下面小編就為大家分享一篇android 判斷網(wǎng)絡(luò)是否可用與連接的網(wǎng)絡(luò)是否能上網(wǎng),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01Android帶依賴樹(shù)的aar是如何生成的(推薦)
這篇文章主要介紹了Android打帶依賴樹(shù)的aar的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2018-01-01android獲取相冊(cè)圖片和路徑的實(shí)現(xiàn)方法
這篇文章主要介紹了android獲取相冊(cè)圖片和路徑的實(shí)現(xiàn)方法,本文介紹的是Android4.4后的方法,感興趣的小伙伴們可以參考一下2016-04-04Flutter?LinearProgressIndicator使用指南分析
這篇文章主要為大家介紹了Flutter?LinearProgressIndicator使用指南分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03Android中制作自定義dialog對(duì)話框的實(shí)例分享
這篇文章主要介紹了Android中制作自定義dialog對(duì)話框的實(shí)例分享,安卓自帶的Dialog顯然不夠用,因而我們要繼承Dialog類來(lái)制作自己的對(duì)話框,需要的朋友可以參考下2016-04-04