EditText カーソル ポインターの色を (原色の青から白に) 変更しようとしていますが、私のプロジェクトでは解決策がありません。同じコードが正常に動作するデモ プロジェクトを開発しようとしました。このコードは >= Android 5.0 で正常に動作しています
どの属性が私の値で上書きされるのかわかりません。この問題に遭遇するには、次の 2 つのオプションがあります。
- そのカラー値を制御している属性を見つけます。
- ページのロード時 (onViewCreated 内) に Java コードで色の値を変更します。
この問題を解決する方法を提案してください。
スタイル.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="my_text_layout_style">
<item name="android:textColor">#FFF</item>
<item name="android:textColorHint">#FFF</item>
<item name="colorAccent">#FFF</item>
<item name="colorControlNormal">#FFF</item>
<item name="colorControlActivated">#FFF</item>
<item name="colorControlHighlight">#FFF</item>
</style>
<style name="my_edit_text_style">
<item name="colorAccent">#FFF</item>
<item name="android:editTextStyle">@style/MyEditTextStyle</item>
</style>
<style name="MyEditTextStyle" parent="Widget.AppCompat.EditText" />
</resources>
レイアウト.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/base_disable_btn_bg_color"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:hint="just a hint"
app:hintTextAppearance="@style/my_text_layout_style"
android:theme="@style/my_text_layout_style"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:theme="@style/my_edit_text_style"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
プログラムでビューを追加しようとしましたが、成功しませんでした
AppLinearLayout appLinearLayout = (AppLinearLayout) view.findViewById(R.id.some_id);
EditText editText = new EditText(new ContextThemeWrapper(getContext(), R.style.AppTheme_Cursor));
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editText.setLayoutParams(params);
appLinearLayout.addView(editText);