2017-07-16 67 views
1

我正在爲應用程序創建UI,我不知道在Android中創建此類按鈕的更有效方式是什麼。它具有複選框(已勾選\ unchecked狀態)等行爲,但必須看起來像普通按鈕。我要像截圖上創造的東西:在這種情況下什麼類型的視圖更好? (截圖附後)

enter image description here

我可以自定義複選框來得到這個結果,或者我應該使用textviews或也許其他類型的意見?我需要處理這個按鈕狀態,最好的辦法是什麼?

+1

你可以使用[複合按鈕(https://developer.android.com/reference/android/widget/CompoundButton的.html) – codeMagic

回答

0

您可以創建bg.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listview_background_shape"> 
    <stroke 
     android:width="2dp" 
     android:color="#ff207d94" /> 
    <padding 
     android:bottom="2dp" 
     android:left="2dp" 
     android:right="2dp" 
     android:top="2dp" /> 
    <corners android:radius="5dp" /> 
    <solid android:color="#00000000" /> 
</shape> 

,並設置爲背景

相關問題