How do I make this picture in android drawable.xml format?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/wallpaper"></bitmap>
</item>
</layer-list>
You can defined the drawable directly as layer-list item:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@drawable/wallpaper"/>
</layer-list>
The drawable will expand to fit your container. Notice that I didn't modify the bottom inset ( android:bottom
) so that the curve remains flush with the bottom of your container. You can modify the left
, right
, top
and bottom
attributes to get your desired curve.
rounded_header.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="-100dp"
android:left="-400dp"
android:right="-400dp">
<shape android:shape="oval">
<gradient
android:startColor="#F07B26"
android:endColor="#F8BA4C"/>
</shape>
</item>
</layer-list>
layout.xml
<View
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/rounded_header"/>
Result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.