2016-08-03 93 views
0

我使用AppCompatEditText我的佈局是EDITTEXT變線顏色和文本顏色不同

<android.support.design.widget.TextInputLayout 
    android:id="@+id/text_input_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <com.app.dream11.UI.CustomEditTextView 
     android:id="@+id/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Enter your name" 
     CustomEditTextView:fontType="Xanadu" /> 
</android.support.design.widget.TextInputLayout> 

風格我已經定義爲

<style name="Widget.Design.TextInputLayout" parent="AppTheme"> 
    <item name="hintTextAppearance">@style/AppTheme.TextFloatLabelAppearance</item> 
    <item name="errorTextAppearance">@style/AppTheme.TextErrorAppearance</item> 
    <item name="counterTextAppearance">@style/TextAppearance.Design.Counter</item> 
    <item name="counterOverflowTextAppearance">@style/TextAppearance.Design.Counter.Overflow 
    </item> 

</style> 

<style name="AppTheme.TextFloatLabelAppearance" parent="TextAppearance.Design.Hint"> 
    <!-- Floating label appearance here --> 
    <item name="android:textColor">@color/warm_grey_two</item> 
</style> 

<style name="AppTheme.TextErrorAppearance" parent="TextAppearance.Design.Error"> 
    <!-- Error message appearance here --> 
    <item name="android:textColor">@color/pale_red</item> 
    <item name="colorControlHighlight">@color/denim_blue</item> 


</style> 

<!-- edittext line color --> 
    <item name="colorControlNormal">@color/white_four</item> 
    <item name="colorControlActivated">@color/greyish_brown</item> 
    <item name="editTextStyle">@style/App_EditTextStyle</item> <!-- For compatibility with the support library --> 

</style> 

,但現在的問題是,當我設置edittext的線顏色說藍色,然後文字顏色也變成藍色但我想 線顏色守LD是不同的,文字顏色也不同

回答

0

對此基色和colorAccent一起來看看這些被用來對焦點編輯文本行的顏色變化,並着重就改變它

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> //this color change your line color of edittext 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 

    <item name="colorAccent">@color/colorAccent</item> 
    <item name="android:textColor">@color/colorPrimary</item> 
    //text color of edittext 
    <item name="colorControlNormal">@color/white_four</item> 
    <item name="colorControlActivated">@color/greyish_brown</item> 

</style> 
+0

所以在我的情況,我有不同的顏色對主旋律初級 – andro

+0

使用這種.......並根據需要對colorprimary和coloraccent –

+0

的變線沒有得到你檢查我的代碼更改顏色 – andro

0

風格.XML

<style name="EditTextCustom" parent="android:Widget.EditText"> 
    <item name="android:background">@drawable/apptheme_edit_text_holo_light</item> 
    <item name="android:textColor">#ffffff</item> 
</style> 

XML代碼:

<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    style="@style/EditTextCustom"/> 
+0

@andro你試試這個嗎? –