2014-10-06 127 views

回答

0

然後用使用selectorcustomstyle.xml繪製,並以此爲背景對您的按鈕自定義顏色。示例代碼對我來說工作得很好。

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:state_pressed="true" > 
    <shape> 
     <solid 
      android:color="#f8f9fa" /> 
     <stroke 
      android:width="1dp" 
      android:color="#d2d2d2" /> 
     <corners 
      android:radius="1dp" /> 
    </shape> 
</item> 
<item> 
    <shape> 
     <gradient 
      android:startColor="#f8f9fa" 
      android:endColor="#d2d2d2" 
      android:angle="270" /> 
     <stroke 
      android:width="1dp" 
      android:color="#d2d2d2" /> 
     <corners 
      android:radius="1dp" /> 
    </shape> 
</item> 
</selector>