XMLファイル:android:drawableBottom属性と組み合わせて使用すると描画可能な図形が表示されません。 RES /描画可能/ gradient_box.xmlに保存
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFF0000"
android:endColor="#80FF00FF"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>
(上記の形状定義は、その後のAndroid開発者向けガイドから取られていることに誤りはありません。。)。
はのは、TextViewのと一緒にそれを使用してみましょう:
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text with some crazy rectangle shape below it."
android:drawableBottom="@drawable/gradient_box"/>
のTextViewが表示drawableBottom属性が存在しなかったかのように!しかしながら、背景としての形状を設定するだけで正常に動作:アンドロイドに実際の画像(例えば、*の.PNG)を設定
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text with crazy background"
android:background="@drawable/gradient_box"/>
:drawableBottomも正常に動作します。
アイデア?
このような場合は、match_parentの幅を設定することはできません。 –
グラデーション描画をプログラムで設定したときにグラデーション描画を設定するには、ここでは https://stackoverflow.com/questions/8481322/create-a-radial-gradient-programmatically – foo