我想创建渐变背景,其中渐变位于上半部分,下半部分为纯色,如下图所示:
我不能,因为它会centerColor蔓延到底部和顶部。
centerColor
如何制作像第一张图片一样的背景?我怎样才能使centerColor不散开的小?
这是上面背景按钮的 XML 中的代码。
<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>
您可以通过使用 xml图层列表将顶部和底部“带”组合到一个文件中来创建这种“半渐变”外观。每个波段都是一个 xml 形状。