自定義RadioButton樣式并去除默認樣式位置
做項目的遇到要自定義RadioButton的樣式,在網上搜索了很多例子都沒有完美解決,當android:button="@null"的是時 候但它的位置還在,空出了很大一塊,橫向排列的時候不是很美觀。試了很多辦法終于解決了這個小問題就是把背景 也 設 為"@null" 這樣:android:background="@null" ,就可以了 它的也就沒有了 空出的很大部分也沒有 了。
全部代碼:
[mw_shl_code=xhtml,true]android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="15dp"
android:paddingTop="15dp" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="保額"
android:textColor="#363636"
android:textSize="18sp" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@null"
android:button="@null"
android:drawableLeft="@drawable/radio_selector"
android:singleLine="true"
android:text="10萬"
android:textColor="#2991a5"
android:textSize="18sp" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@null"
android:button="@null"
android:drawableLeft="@drawable/radio_selector"
android:singleLine="true"
android:text="20萬"
android:textColor="#2991a5"
android:textSize="18sp" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@null"
android:button="@null"
android:drawableLeft="@drawable/radio_selector"
android:singleLine="true"
android:text="50萬"
android:textColor="#2991a5"
android:textSize="18sp" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@null"
android:button="@null"
android:drawableLeft="@drawable/radio_selector"
android:singleLine="true"
android:text="100萬"
android:textColor="#2991a5"
android:textSize="18sp" />
[/mw_shl_code]
推薦文章
2025-01-18
2024-11-28
2024-11-09
2024-10-25
2024-06-25
2024-01-04
2023-11-06
2023-10-30
2023-10-13
2023-10-10
穩定
產品高可用性高并發貼心
項目群及時溝通專業
產品經理1v1支持快速
MVP模式小步快跑承諾
我們選擇聲譽堅持
10年專注高端品質開發