更新时间:2023-11-17 17:02:04
您可以创建这个半渐变使用xml 图层列表,将顶部和底部的乐队组合成一个文件每个乐队都是一个xml形状。
有关详细的教程,请参阅SO上的以前的答案:多梯度形状。
I want to create gradient background as in the picture. but it can't because of the centerColore was spread out to cover bottom and top.
How can I make a background like picture below? or How can I make small ceterColor that not spread out? did you have any idea?
This is the background that i want.
This is the background that I made.
This is code in xml of background button above
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:startColor="#6586F0"
android:centerColor="#D6D6D6"
android:endColor="#4B6CD6"
android:angle="90"/>
<corners
android:radius="0dp"/>
</shape>
You can create this 'half-gradient' look by using an xml Layer-List to combine the top and bottom 'bands' into one file. Each band is an xml shape.
See this previous answer on SO for a detailed tutorial: Multi-gradient shapes.