我有一個線性佈局,其中包含三個圖像按鈕。每個圖像按鈕都有不同的顏色。在初始時間,所有圖像按鈕都未被選中。如果選擇了圖像按鈕(藍色V
將與圖像按鈕背景重疊),並且未選中另一個圖像按鈕,我想爲圖像按鈕進行選中/選擇。我怎麼能在android中做到這一點?在Android中設置選中/選擇的圖像按鈕
這是我的佈局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="7dp"
android:layout_centerInParent="true">
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/color1"
android:background="@color/colorAccent"/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/color2"
android:layout_marginLeft="5dp"
android:background="@color/colorPrimaryDark" />
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/color3"
android:layout_marginLeft="5dp"
android:background="@color/colorPrimary"/>
</LinearLayout>
更新:藍色V
來檢查狀態。這是一個類似的結果
什麼是藍色v?你的意思是你只能選擇3箇中的1個?沒有多重選擇?請詳細說明 –
'V'表示選中狀態。它在檢查時看起來是複選框。你是對的。我只想要一次檢查,而不是多次檢查 – Jame
你想要單次檢查的邏輯,而不是多次檢查每個圖像點擊嗎? –