を使用してテキストの上にグラデーションを追加しようとしていますShapeDrawable
。目標は、画面の左右のテキストをフェードさせることです。レイアウトは次のとおりです。
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/text_view"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Lorem ipsum dolor sit amet"
android:textColor="#000"
android:textSize="18sp"/>
<View
android:layout_height="wrap_content"
android:layout_width="60dp"
android:layout_alignTop="@id/text_view"
android:layout_alignBottom="@id/text_view"
android:background="@drawable/gradient_shape"/>
<View
android:id="@+id/line"
android:layout_height="2dp"
android:layout_width="30dp"
android:layout_below="@id/text_view"
android:background="#00f"/>
<View
android:layout_height="2dp"
android:layout_width="60dp"
android:layout_below="@id/line"
android:background="#f00"/>
</RelativeLayout>
勾配ShapeDrawable
:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ffffffff"
android:endColor="#00ffffff"
android:type="linear"
/>
</shape>
問題は、私のHTC Desire
HD ではグラデーションが滑らかでないことです。画面上では次のように表示されます: (品質については申し訳ありませんが、画像はフォト エディターでわずかに調整されており、効果がより見やすくなっています)
このグラデーションの線がグラデーション ドローアブルの中心に表示されることがわかりました。グラデーションの下の青い線がこれを示しています。これを修正する方法を教えてもらえますか?デバイス上では、これは悪く見えます。
このアプリをエミュレーターで実行しようとしましたが、Ritmix-RMP-470
すべて問題ないようです。グラデーションが滑らかで美しい。しかし、HTC Desire
HD では問題が存在します。また、を使用してデバイスからスクリーンショットを撮ろうとしましたDDMS
。スクリーンショットでもすべて問題ないように見えます:
PNG
フォトエディターでグラデーション画像を作成してから、png
代わりにこれを使用しようとしましShapeDrawable
た。結果はまだ同じです。
グラデーションでこの視覚的な問題を回避する方法はありますか?