1

我的编辑文本现在看起来像这样(就像它的背景一样) http://prntscr.com/843323

这是代码

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

 <item>
   <shape  xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
       <solid android:color="@android:color/transparent" />
   </shape>
 </item>
</selector>

当我点击它来写东西时,如何为这个编辑文本(例如白色)设置下划线.. http://prntscr.com/8434s7

4

2 回答 2

2

尝试这个:

如何在 Android 中更改 EditText 的焦点颜色

或这个:

<style name="Theme.MyTheme.EditText" parent="AppTheme">
    <item name="colorControlNormal">#ff6600</item>
    <item name="colorControlActivated">#ff6600</item>
</style>


<EditText
        style="@style/TextAppearance.AppCompat.Display1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/materialDesignEditText"
        android:ems="10"
        android:hint="Normal EditText"
        android:padding="5dp"
        android:singleLine="true"
        android:textColor="#000000"
        android:textColorHint="@android:color/secondary_text_dark"
        android:textSize="15dp"
        android:theme="@style/Theme.MyTheme.EditText" />
于 2015-08-13T09:00:00.407 回答
0

创建 textfield_default

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="Color Hash Code"
        android:endColor="@color/background_material_light"
        android:angle="90" />
</shape>

在drawable中创建edit_text.xml

    <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>

<EditText
        style="@drawable/edit_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/materialDesignEditText"
        android:ems="10"
        android:hint="Text here"
        android:padding="5dp"
        android:singleLine="true"
        android:textColor="#000000"
        android:textColorHint="@android:color/secondary_text_dark"
        android:textSize="15dp" />
于 2015-08-13T10:46:57.457 回答