Androidの円形グラデーション 質問する

Androidの円形グラデーション 質問する

画面の中央から白く放射され、画面の端に向かって移動するにつれて黒に変わるグラデーションを作成しようとしています。

このような「通常の」グラデーションを作成するときに、さまざまな形状を試しています。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#E9E9E9" android:endColor="#D4D4D4"
        android:angle="270"/>
</shape>

「楕円形」を使用すると、少なくとも丸い形は得られましたが、グラデーション効果はありませんでした。どうすればこれを実現できますか?

ベストアンサー1

円形グラデーションを作成するには、次の操作を実行しますandroid:type="radial"

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:type="radial" android:gradientRadius="250dp"
        android:startColor="#E9E9E9" android:endColor="#D4D4D4" />
</shape>

おすすめ記事