0
通常,按下按鈕時會有點效果。但是,當我設置漸變背景的按鈕,通過創建一個形狀border.xml:按形狀設置漸變背景時按鈕的丟失效果
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1px" android:color="#cccccc" />
<corners android:radius="6px" />
<gradient
android:startColor="#d8d8d8"
android:endColor="#f9f2f9"
android:angle="90" />
</shape>
和按鈕:
<Button
android:id="@+id/visibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:drawableLeft="@drawable/idle"
android:singleLine="true"
android:padding="5px"
android:textSize="14px"
android:textColor="#444444"
android:textStyle="bold"
android:typeface="sans"
android:layout_marginLeft="5px"
android:layout_marginRight="5px"
android:background="@drawable/border"
android:clickable="true">
</Button>
當按下按鈕時失去了效果,按鈕現在就像是一個textview,當我點擊它時沒有任何改變。 但如果我在按鈕刪除這條線,一切正常:
android:background="@drawable/border"
因此,任何解決方案,以不失去效果時按下按鈕,或任何解決方案,使一個按鈕有邊框漸變背景不使用形狀? 謝謝!
這在文檔中的「按鈕樣式」下更詳細地描述:http://developer.android.com/reference/android/widget/Button.html – 2011-05-16 14:35:46
爲每個狀態提供不同的背景圖像比我想要的要多,當我按下按鈕時,我只想效果回來,現在它就像帶有邊框的文本視圖 – Leo 2011-05-16 14:37:28
@LeoLink:然後擺脫您的自定義背景。 – CommonsWare 2011-05-16 14:57:31