您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關(guān)怎么在Android中自定義View實現(xiàn)投票進度條,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。
功能屬性介紹
<!-- MatchSupportProgressBar --> <declare-styleable name="MatchSupportProgressBar"> <!-- 進度條圓角角度 --> <attr name="progress_radio" format="string"></attr> <!-- 進度條左側(cè)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> <!-- 進度條左側(cè)Tag文本顏色 --> <attr name="progress_tag_text_color" format="color"></attr> <!-- 進度條左側(cè)Tag文本尺寸 --> <attr name="progress_tag_text_size" format="dimension"></attr> <!-- 進度條右側(cè)百分比文本顏色 --> <attr name="progress_percent_text_color" format="color"></attr> <!-- 進度條右側(cè)百分比文本尺寸 --> <attr name="progress_percent_text_size" format="dimension"></attr> <!-- 進度條右側(cè)百分比文本 --> <attr name="progress_percent_text" format="string"></attr> <!-- 進度條選中的圖標與進度條、文字的間距 --> <attr name="progress_offsetX" format="dimension"></attr> <!-- 進度條右側(cè)文字的水平偏移量 --> <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="杰倫;那英;汪峰"設(shè)置 了幾個字符串,getPercentList就要傳幾個字符串) 參數(shù)2:得到一個boolean類型的集合,用于設(shè)置進度條√顯示的位置 參數(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);
關(guān)于怎么在Android中自定義View實現(xiàn)投票進度條就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。