Android自定義View實現(xiàn)投票進度條
更新時間:2019年11月20日 11:04:38 作者:姜絲兒jlq
這篇文章主要為大家詳細介紹了Android自定義View實現(xiàn)投票進度條,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了Android投票進度條的具體代碼,供大家參考,具體內容如下
效果展示
功能屬性介紹
<!-- MatchSupportProgressBar --> <declare-styleable name="MatchSupportProgressBar"> <!-- 進度條圓角角度 --> <attr name="progress_radio" format="string"></attr> <!-- 進度條左側Tag文本 --> <attr name="progress_tag_text" format="string"></attr> <!-- 進度條已填充部分顏色 --> <attr name="progress_reach_color" format="color"></attr> <!-- 進度條已填充部分高度 --> <attr name="progress_reach_height" format="dimension"></attr> <!-- 進度條背景顏色 --> <attr name="progress_background_color" format="color"></attr> <!-- 進度條背景高度 --> <attr name="progress_background_height" format="dimension"></attr> <!-- 進度條左側Tag文本顏色 --> <attr name="progress_tag_text_color" format="color"></attr> <!-- 進度條左側Tag文本尺寸 --> <attr name="progress_tag_text_size" format="dimension"></attr> <!-- 進度條右側百分比文本顏色 --> <attr name="progress_percent_text_color" format="color"></attr> <!-- 進度條右側百分比文本尺寸 --> <attr name="progress_percent_text_size" format="dimension"></attr> <!-- 進度條右側百分比文本 --> <attr name="progress_percent_text" format="string"></attr> <!-- 進度條選中的圖標與進度條、文字的間距 --> <attr name="progress_offsetX" format="dimension"></attr> <!-- 進度條右側文字的水平偏移量 --> <attr name="progress_offsetR" format="dimension"></attr> <!-- 進度條之間的偏移量 --> <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使用示例
//進度條的點擊事件監(jiān)聽 mspb.setOnRightTextClickListener(new OnRightTextClickListener() { @Override public void onClick(int position) { //position是點擊的位置 } });
/* 為進度條賦值: 參數(shù)1:是我們算好的進度值,一般由服務器返回。(注: yjcp:progress_tag_text="杰倫;那英;汪峰"設置 了幾個字符串,getPercentList就要傳幾個字符串) 參數(shù)2:得到一個boolean類型的集合,用于設置進度條√顯示的位置 參數(shù)3:true表示已投票,false表示未投票 參數(shù)4:是否開啟動畫特效 */ mspb.setPercentState(getPercentList("10","90","100"), getCheckList(position), true, true);
//重置進度條狀態(tài),如果在listview中涉及到復用問題條用它即可。 //參數(shù):true投過票,false未投過 mspb.setState(false);
源碼下載:Android投票進度條
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Android基于OpenGL的GLSurfaceView創(chuàng)建一個Activity實現(xiàn)方法
這篇文章主要介紹了Android基于OpenGL的GLSurfaceView創(chuàng)建一個Activity實現(xiàn)方法,結合實例形式分析了Android中OpenGL圖形操作類GLSurfaceView的功能、用法及相關使用技巧,需要的朋友可以參考下2016-10-10android 判斷網(wǎng)絡是否可用與連接的網(wǎng)絡是否能上網(wǎng)
下面小編就為大家分享一篇android 判斷網(wǎng)絡是否可用與連接的網(wǎng)絡是否能上網(wǎng),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01Flutter?LinearProgressIndicator使用指南分析
這篇文章主要為大家介紹了Flutter?LinearProgressIndicator使用指南分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-03-03