私はリソースに定義された色に依存するアプリを書いています。レイアウトXMLファイルに直接設定されるものと、コードで設定されるものがあります。例:res/values/styles.xml
でアンドロイド:textColorがMarshmallowで動作しなくなった
色の定義:
<color name="orvGyro">#33B5E5</color>
レイアウト:コード内
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dotSpace"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/orvGyro" />
カラー:
accStatus.setTextColor(getResources().getColor(R.color.somecolor));
これは持っているロリポップ、までアプリのターゲットのAPI 17適切な色を表示して完璧に作業しました。 Marshmallow(Cyanogenmod 13)に移行した後、これらの色はすべてオレンジ色で表示されます。 Javaコードで定義され、リソースでは定義されていない他の色は、正しく表示されているようです。
ターゲットAPIを23に変更し、API 21+のスタイルを追加してみましたが、役に立たなかったことがあります。
ここで何が間違っていますか?これはCyanogenMod13のバグですか?何か間違っていますか?
編集:それはリソースから色を得ることではないようです。
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dotSpace"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#669900" />
EDIT 2:ちょうどAndroid M Developer Preview - TextView android:textColor being ignored出くわしも以下のように色をハードコーディングすることは私にオレンジ色のテキストを提供します。これは私が経験している行動を説明できますか?
編集3:レイアウトを使用する代わりにコンテンツを動的に生成すると、色が正しく表示されます。例:
TextView newType = new TextView(rilLteCells.getContext());
newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
newType.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
newType.setTextColor(rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
newType.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));
row.addView(newType);
レイアウトで直接設定した色についてはどうすればよいですか? – user149408
あなたのカラーリソースから適切な色を取ります。 –
それはまったく動作しないものです。レイアウトでカラーリソースを指定しても、オレンジ色で表示されます。 – user149408