39

次の画像のようなものが欲しい

ここに画像の説明を入力

drawable shape を使ってみた

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
    android:angle="360"
    android:centerX="50%"
    android:centerY="50%"

    android:gradientRadius="50%"
    android:endColor="#000000"
    android:centerColor="#FFFFFF"
    android:startColor="#000000" >
</gradient>
</shape> 
4

5 に答える 5

89

ドローアブル フォルダーに新しい Android xml ファイル (たとえば、GreyRadial.xml) ファイルを作成します。

あなたのxmlファイルで

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <gradient
        android:centerColor="#c1c1c1"
        android:endColor="#4f4f4f"
        android:gradientRadius="400"
        android:startColor="#c1c1c1"
        android:type="radial" >
    </gradient>

</shape>

を使用して、レイアウトの背景でこの xml を使用します。

android:background="@drawable/GreyRadial"
于 2013-10-23T13:15:43.207 に答える
13

もう1つの解決策:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <gradient
        android:centerX="50%"
        android:centerY="50%"
        android:endColor="@android:color/black"
        android:gradientRadius="100%"
        android:startColor="@android:color/transparent"
        android:type="radial"/>
</shape>
于 2017-05-10T13:22:24.350 に答える
1

ここに問題に対する私の解決策があります。

<shape android:shape="rectangle">

 <gradient
     android:endColor="@color/your_dark_color"
     android:startColor="@color/your_light_color"
     android:type="radial"
     android:gradientRadius="700"/>

Iの値を変更することでandroid:gradientRadius、正確な結果を得ることができました。

于 2015-11-13T11:49:43.303 に答える