2016-08-19 136 views
1

我需要在xml中將EditText的光標顏色和底線顏色更改爲#FFFFFF如何在xml中更改EditText光標和底線顏色?

我該怎麼做?

enter image description here

我styles.xml:

<resources> 

    <style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> 
     <item name="android:actionMenuTextColor">@color/toolbar_text_color</item> 
     <item name="colorAccent">#FFFFFF</item> 
     <item name="colorPrimary">#FFFFFF</item> 
     <item name="android:editTextStyle">@style/EditTextStyle</item> 
     <!--<item name="actionMenuTextColor">@color/toolbar_text_color</item>--> 
    </style> 


    <!-- Toolbar theme. --> 
    <style name="ToolbarTheme" parent="@style/Theme.AppCompat.NoActionBar"> 
     <item name="actionMenuTextColor">@color/toolbar_text_color</item> 
     <item name="android:actionMenuTextColor">@color/toolbar_text_color</item> 
     <item name="android:textColorSecondary">@color/hockeyapp_button_background_pressed</item> 
     <item name="android:textColor">@color/toolbar_text_color</item> 
     <item name="android:background">@color/toolbar_bg_color</item> 
    </style> 

    <style name="EditTextStyle" parent="Widget.AppCompat.EditText"> 
     <item name="colorControlNormal">#FFFFFF</item> 
     <item name="colorControlActivated">#FFFFFF</item> 
     <item name="colorControlHighlight">#FFFFFF</item> 
    </style> 
</resources> 

Definitinion的EditText的:

<EditText 
    android:id="@+id/ed_profile_id" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fontFamily="sans-serif" 
    android:hint="Profile id" 
    android:textColorHint="@color/white" 
    android:textSize="20dp" 
    android:layout_marginTop="20dp" /> 

回答

4

使用材料設計的EditText。鏈接此Material Edit Text Library

搖籃行添加:

compile 'com.rengwuxian.materialedittext:library:2.1.4' 
+2

非常感謝您!它有助於! –

相關問題