我試圖用3d的樣子來製作一個自定義的按鈕樣式,但是我遇到了按鈕「已按下」狀態的問題。該按鈕可以正確更改圖像,但文字保持不動,這使得文字看起來好像在印刷機上向上滑動。Android中的9個補丁按鈕問題
(紅色線加到顯示了取消按鈕的基線)
XML爲按鈕視圖(cmdNegative被取消按鈕,layDialogControl是直接上方的按鈕的佈局)
<Button
android:id="@+id/cmdPositive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_positive"
android:text="Accept"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintTop_toBottomOf="@+id/layDialogControl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/cmdNegative"
app:layout_constraintBottom_toBottomOf="parent" />
用於按鈕樣式的XML(button_gray與button_green完全相同,只是...以及灰色)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:drawable="@drawable/button_gray" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/button_green_pressed" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/button_green_pressed" />
<item
android:state_enabled="true"
android:drawable="@drawable/button_green" />
</selector>
據我瞭解,設置在右邊的像素/底部應該已經明確了「內容區」和文本應留在內容視圖,buuuuuuut不是這種情況。任何想法或指針,我已經搞砸了,將不勝感激。
關於我已刪除的編輯,值得注意的是,downvotes並非_necessarily_粗魯 - 更多的時候它們只是消息。如果有人帶着一些可操作的反饋伴隨DV,這是理想的,但他們沒有義務。一般來說,我會建議不要擔心他們。 – halfer
是的,這是偉大的,所有,但無論問題仍然沒有答案,現在可能永遠不會得到答案,因爲它會被埋在任何搜索結果。當最終結果相同時,原因並不重要。 –
社區的最終結果是不同的 - 但如果我們宣傳downvotes總是侮辱的不真實情況,那麼更多SO用戶會認爲它們是敵對行爲,但這可能不是選民的意圖。 – halfer