我想在背景上使用較小的圖片/背景色,但我希望較小圖片/背景的邊緣具有漸變邊緣,因此它不僅僅是方形的磚。如何在Android上使用具有漸變邊緣的背景或圖像?
下面的代碼我有我的FrameLayout的背景圖像和的FrameLayout裏面的白色在我的LinearLayout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
tools:context="com.example.snake.LevelScoreActivity"
tools:ignore="MergeRootFrame"
android:background="@drawable/snakebackground">
<TextView
android:id="@+id/outputTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:text="Level X Score"
android:textSize="14dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:background="#ffffff">
<TextView
android:id="@+id/output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:text="Username" />
<TextView
android:id="@+id/output2"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:text="Score" />
<TextView
android:id="@+id/output3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:text="Timestamp" />
</LinearLayout>
<TextView
android:id="@+id/outputNoScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:layout_gravity="center"
android:text=""
android:textSize="14dp"/>
</FrameLayout>
我怎樣才能做到這一點?
我的第一個直覺是用透明膠片定製'GradientDrawable'。但我不確定這是否可以用'GradientDrawable'。 –
只是簡單的自定義BitmapDrawable將會訣竅 – pskink