![](/img/trans.png)
[英]Android - How to create image button of different states, default , pressed and focussed
[英]Button to be focussed & in default selected condition
我正在顯示移動應用程序的“條款和條件”屏幕作為第一個屏幕。
我正在使用布局文件來顯示屏幕。
在布局文件中,我有兩個按鈕,一個用於接受,一個用於拒絕
<Button android:id="@+id/acceptBtn" android:text="@string/accept"
android:background="@drawable/buttons" android:textColor="@color/white"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:id="@+id/rejecttBtn" android:text="@string/reject"
android:background="@drawable/buttons" android:textColor="@color/white"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
默認要求為,“拒絕”按鈕應處於選中狀態。 另外,目前,由於android:background =“ @ drawable / buttons”是圖像,因此按鈕未聚焦。
請提供您的輸入信息/示例代碼/ xml以解決該問題。
提前致謝。
問題在於按鈕上的焦點指示器僅是背景圖像。 因此,當您使用可繪制對象設置背景時,當按鈕更改其狀態時,禁止系統使用聚焦的背景圖像。
一個簡單的解決方案是使用ImageButtons
並將您的drawable設置為src
屬性。 然后,您將有一個按鈕,圖像居中。 基礎背景可以更改為默認的焦點背景圖像。 如果您不希望圖像下方的灰色區域仍想使用按鈕,則必須根據按鈕的狀態來定義風俗習慣。 請在此類似的帖子中查看: 刪除EditText的焦點邊框
在那里,我已經解釋了這種情況。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.