1

ドローアブルだけを使用して、外側に放射状の白いぼかしのある黒い背景を作成することは可能ですか?

最終製品は次のようになります。歯車はImageViweで、テキストはTextViewですが、黒と白のぼかしを単一の描画可能にして、含まれているLinearLayoutに割り当てることができます。

ここに画像の説明を入力してください

レイアウトのコードは次のとおりです(最終的にはGridViewで使用されます)。可能であれば、LinearLayoutの背景を前述のDrawableに設定したいと思います。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:background="#000000"
    android:gravity="center_vertical|center_horizontal"
    android:orientation="vertical"
    android:padding="5dp" >

    <ImageView
        android:id="@+id/tile_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:adjustViewBounds="true"
        android:contentDescription="@string/temp_image"
        android:src="@drawable/ic_logo" />

    <TextView
        android:id="@+id/tile_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>
4

1 に答える 1

9

確かに、以下は放射状のグラデーション描画可能であり、背景として使用されます。色/グラデーションの半径を変更して、目的の効果を取得します。(ドローアブルフォルダ " radialbg "、またはお好みの名前でxmlファイルを作成します)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"      
        android:shape="rectangle">
<gradient
    android:startColor="#FFFFFFFF"
    android:endColor="#00FFFFFF"
    android:gradientRadius="270"
    android:type="radial"/>

</shape>

適用するには、linearlayoutで次の行を使用します

android:background="@drawable/radialbg">
于 2012-05-31T16:16:40.430 に答える