次のコードを使用して、一部の Android テキスト ビューで古いスタイルの 8 ビット効果を作成しようとしています。
private static Shader InversetextShader = new LinearGradient(0, 0, 0, 22,
new int[] { Color.RED, Color.BLUE },
new float[] { 0, 1 }, TileMode.CLAMP);
TextView t1 = (TextView) findViewById(R.id.textView2);
t1.setText(getApplicationContext().getString(R.string.app_name_mele));
t1.getPaint().setShader(InversetextShader);
t1.setTypeface(font);
t1.setShadowLayer(4f, 2.0f, 2.0f, Color.BLACK);
コードは Android < 3 で動作していますが、ICS (API レベル 14) をターゲットにし始めてから問題が発生しています。
TextView は非常に単純です。
<TextView
android:id="@+id/textViewRecords1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
これは、欠陥を示す画像です。存在しないはずの黒い線がいくつかあります。
(画像載せれなくてごめんなさい)
http://i.stack.imgur.com/xRWOM.png
ディスプレイをオフにして(つまり、電話をロックして)再度オンにすると、欠陥はなくなります。私はすでに .invalidate() を呼び出してビューを再度描画しようとしましたが、成功しませんでした。