2016-05-17 10 views
1

edittextにフォーカスがあるときに、その色を変更したedittextを持つアプリケーションを作成しています。私は2つの9のパッチを作成して、背景を設定し、このXMLによるが、試してみたスタイルEditTextアンダーラインカラーandroid

enter image description here

:ビューにフォーカスがあるときには、このような何かを白い色を持っている必要がある場合、通常の色は、青でなければなりませんその機能していないようです。どのように私はこれを達成することができます誰に教えてください?

のXmlセレクター:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_enabled="true" android:state_focused="true" 
     android:drawable="@drawable/spelling_blue" /> 
    <item android:state_window_focused="false" android:state_enabled="true" 
     android:drawable="@drawable/spelling_white" /> 
    <item android:drawable="@drawable/spelling_white" /> 
</selector> 

おかげ

+0

http://stackoverflow.com/questions/35262935/android-edittext-bottom-line-color-and-theme-changes/35263829#35263829はそれに役立つことを願って、これを試してください君は。 –

+0

どのようなリソースがありますか? spelling_blueとspelling_whiteを表示できますか? – manao

+1

<?xml version = "1.0" encoding = "utf-8"?> <セレクタxmlns:android = "http://schemas.android.com/apk/res/android"> android:state_focused = "true" android:drawable = "@ drawable/spelling_blue" /> Alexander

答えて

0

私はあなたがandroid:state_window_focusedを使用する必要はないと思います。

これを試してみてください:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:state_pressed="true" 
     android:drawable="@drawable/spelling_blue" /> <!-- pressed -->  
    <item 
     android:state_focused="true" 
     android:drawable="@drawable/spelling_blue" /> <!-- focused -->  
    <item 
     android:drawable="@drawable/spelling_white" /> <!-- default --> 
</selector>