簡體   English   中英

在Android中自定義單選按鈕

[英]Customizing radiobuttons in android

我擴展了我在stackoverflow中問了幾次的問題-這里


如答案所示-在這里我得到了所需的輸出

我得到的輸出為

在此處輸入圖片說明


我正在嘗試做的事情:

保留所有其他功能,我想顯示image代替Button文本


我怎么能做到這一點

您無法設置文本並設置android:button="@drawable/some_drawable" 而不是 android:button="@android:color/transparent" ,如下所示:

<RadioButton
    android:id="@+id/radio0"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/yourbuttonbackground"
    android:button="@drawable/some_drawable"
    android:checked="true"
/>

您只有3種方法可以在RadioButton中設置可繪制對象:

  • 背景(“邊界圖層列表”需要此背景)
  • 按鈕(推薦)
  • 復合drawable / s(不建議使用,因為位置固定在側面,但是您可能需要嘗試)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM