■レイアウトの背景にグラデーションを設定する
layoutファイルで、背景をグラデーションにしたい場合は、以下のようにします。
まずは次の例のように、グラデーションを設定するxmlファイルを用意し、
「res/drawable」配下に置きます。
[(例) bg_grad.xml ]
--------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FF000000"
android:endColor="#FFFFFFFF"
android:angle="270"
/>
</shape>
--------------------------------------------------------------------------------------
次に、layoutファイルで背景をグラデーションにしたいオブジェクトに対して、
以下を指定します。
android:backgroud="@drawable/bg_grad"
以上