I've been trying to change the baseline color for my edittext when on focus but it doesn't seem to work..
Here's my .xml snippet:
<android.support.design.widget.TextInputLayout
android:id="@+id/til_passwordWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/dimen_10"
android:paddingLeft="@dimen/dimen_10"
android:paddingRight="@dimen/dimen_10"
android:hint="@string/hint_login_password"
>
<android.support.v7.widget.AppCompatEditText
android:id="@+id/password"
android:textSize="17sp"
android:fontFamily="sans-serif"
android:textColor="#000000"
android:textCursorDrawable="#000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
app:backgroundTint="#000000"
android:maxLines="1"
/>
</android.support.design.widget.TextInputLayout>
And here is my styles-v21 file:
<style name="AppTheme" parent="AppTheme.Base">
<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
<item name="colorAccent">@color/ColorPrimary</item>
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowEnterTransition">@android:transition/slide_bottom</item>
<item name="android:windowExitTransition">@android:transition/slide_bottom</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
where : - ColorPrimary = #CD060C (red) - ColorPrimaryDark = #8B181B (darker-red)
I tested this on a Lollipop device and it works great. I can't say the same for my Marshamallow device. I took a look at the issue here on S.O to see how this can be solved for M and above devices. Someone suggested an approach which consist of adding these few lines of code in my activity class:
passwordWrapper.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener(){
@Override
public void onFocusChange(View v, boolean hasFocus){
if (hasFocus)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
v.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.ColorBlackTransparent)));
}
}
}
});
On my Marshmallow device, whenever I focus on the edittext, I keep on having the coloraccent i.e red color for the baseline..I want it to be black..
Does anyone has a workaround on this issue ? Thanks