答案 0 :(得分:1)
在xml文件中添加此radiobutton
<RadioButton
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/home_selector"
android:button="@android:color/transparent"
android:checked="true" />
<RadioButton
android:id="@+id/favourite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/fav_selector"
android:button="@android:color/transparent"
android:checked="true" />
....
现在您可以根据需要为每个不同的单选按钮创建一个选择器
home_selector.xml
<item
android:drawable="@drawable/home_selected"
android:state_checked="true" />
<item
android:drawable="@drawable/home_normal" />
fav_selector.xml
<item
android:drawable="@drawable/fav_selected"
android:state_checked="true" />
<item
android:drawable="@drawable/fav_normal" />
像这样你可以为你想要的单选按钮创建选择器
答案 1 :(得分:-2)
你可以这样做 通过在按钮上方添加颜色的视图
<LinearLayout
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:visibility="visible"
android:background="#000000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher" />
</LinearLayout>
在其点击
上设置其可见性