2016-03-09 106 views
0

我所遇到的,其中像他们改变柜面有一个SetErrorEditText领域改变颜色RedActivity开始这个奇怪的问题。此外,这不会每次都发生,只是在某些情况下才会出现。我如何解决这个错误?任何帮助表示赞赏。 请参阅图像的更多。 这里是代码TextInputLayout改变的EditText颜色为红色

<android.support.design.widget.TextInputLayout 
        android:id="@+id/input_name" 
        style="@style/my_style_textInput" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="8dp"> 

        <EditText 
         android:id="@+id/edt_name" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:hint="Name:" 
         android:inputType="textPersonName" 
         android:singleLine="true" 
         android:textSize="@dimen/subHeading" /> 
       </android.support.design.widget.TextInputLayout> 

这里是风格:

<style name="my_style_textInput" parent="@style/TextAppearance.AppCompat"> 
    //hint color And Label Color in False State 
    <!--<item name="android:textColorHint">@color/item_color</item>--> 
    <!--<item name="android:textColor">@color/colorPrimary</item>--> 
    <item name="android:textSize">@dimen/caption</item> 
    //Label color in True State And Bar Color False And True State 
    <item name="colorAccent">@color/colorPrimary</item> 
    <item name="colorControlNormal">@color/colorPrimary</item> 
    <item name="colorControlActivated">@color/colorPrimaryAccent</item> 
</style> 

请注意,没有colorPrimary,colorAccent和item_color是red.Thank你。 CHECK IMAGE HERE

+0

显示您的XML文本输入布局代码。 –

+0

您的应用程序中是否有任何样式文件适用于您的活动? –

+0

是的,我确实有风格。 – inkedTechie

回答

0

您可以使用此代码自定义颜色。在您的布局

<EditText 
    android:la`enter code here`yout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/login_username" 
    android:hint="@string/username_hint" 
/> 

背景=“@绘制/ edittext_bg”后下绘制和创建文件edittext_bg.xml和里面把这个代码:

应用机器人。

<layer-list> 
<item> 
    <shape android:shape="rectangle"> 
    <!-- Draw a 2dp width border around shape --> 
     <stroke android:color="#ff1e0c" android:width="2dp"/> 
    </shape> 
</item> 
<!-- Overlap the left, top and right border using background color --> 
    <item android:bottom="2dp"> 
    <shape android:shape="rectangle"> 
     <solid android:color="#fffbce"/> 
    </shape> 
    </item> 

希望它可以帮助你。