I m newly in android and making background with gradient from left to right on black to white. I add reference image to make it.
If there is any suggestion, please add me.
Please add below.
res/drawable/gradient_bg.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#ffffff"
android:startColor="#000000" />
<corners
android:topLeftRadius="@dimen/button_radius"
android:topRightRadius="@dimen/button_radius"/>
</shape>
Explain:
angle
0: from Left to Right 90: Bottom to Top 180: Right to Left 270: Top to Bottom
corners
If you want to make the rounded background, add tag: corners
For drawables, there is an attribute
android:autoMirrored="true"
..set this..so when your app locale changes to an RTL support language..drawable will reflect that change
I think that you can use AnimationDrawable, the most basic way it's to have three color: blue, a gradient blue-yellow and yellow:
In res/drawable create a gradient.xml file (left to right):
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#FFFF00"
android:startColor="#0000FF" />
</shape>
Then in the same folder create a animalion-list.xml file:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#0000FF" android:duration="333"/>
<item android:drawable="@drawable/gradient" android:duration="333"/>
<item android:drawable="#FFFF00" android:duration="333"/>
</animation-list>
Apply the animation-list as background to your relative layout:
<RelativeLayout:
android:...
android:...
android:drawable="@drawable/animation-list"
android:... >
...
</RelativeLayout>
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.