我一直在試圖對焦點時改變顏色基線爲我的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被激活 –