我一直在试图对焦点时改变颜色基线为我的EditText,但它似乎没有工作变动EDITTEXT线的颜色..当焦点
,这里是我的.xml片段:
<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>
这是我的风格,V21文件:
<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>
其中: - ColorPrimary =#CD060C(红色) - ColorPrimaryDark =#8B181B(暗红色)
我在一个棒棒糖设备上测试了这个,它效果很好。我不能对我的Marshamallow设备说同样的话。我在这里看看S.O的问题,看看如何解决M和以上设备的问题。有人建议这包括在我的活动类中添加的这几行代码的方法:
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)));
}
}
}
});
在我的棉花糖装置,每当我注重的EditText,我一直在具有coloraccent即红色为基准。 。我希望它是黑色的..
有没有人有解决此问题的方法?由于
是的,我知道如何使用colorControlHighlight和colorControlActivated(I”我已经尝试过了......)。但是,我的应用中有一个导航抽屉,并且将默认的colorControlHighlight更改为黑色将影响我的导航抽屉突出显示颜色。这就是为什么我一直在找活动班的方式直接.. –
@ClaudeHangui我编辑了答案... – rafsanahmad007
我试过你的提议......并且我仍然坚持使用红色(在marshamallow ..)当edittext被激活 –