更改EditText焦点边框

时间:2012-08-08 11:36:02

标签: android android-ui android-theme

我想问一下如何更改EditText边框然后重点关注它。我想将原始的橙色渐变改为我自己的。

2 个答案:

答案 0 :(得分:5)

您可以在drawable文件夹中创建这样的渐变。

  <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
   <shape android:shape="rectangle">
        <gradient
                android:startColor="#5a5a5a88"
                android:endColor="#14141488"
                android:angle="270" android:centerX="0.25"/>

   </shape>
</item>
<item android:top="80dp">
<shape android:shape="rectangle">
        <gradient
                android:startColor="#5aff5a88"
                android:endColor="#14ff1488"
                android:angle="270" android:centerX="0.25"/>

</shape>

    

答案 1 :(得分:3)

在drawable文件夹中创建一个文件。粘贴下面的代码。也可以根据需要提供合适的图像。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_window_focused="false" android:state_enabled="true"     
 android:drawable="@drawable/textfield_default" />
<item android:state_window_focused="false" android:state_enabled="false"       
 android:drawable="@drawable/textfield_disabled" />
   <item android:state_pressed="true" android:drawable="@drawable/textfield_pressed" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected" />
  <item android:state_enabled="true" android:drawable="@drawable/textfield_default" />
  <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_selected" />
 <item android:drawable="@drawable/textfield_disabled" />
</selector>

这将完美无缺。

相关问题