dro*_*ter 2 android shapes xamarin.android android-shape
嗨,我想绘制一个有三个矩形形状的形状:1.纯色2.渐变3.白线我该怎么做?当我尝试这个时,它不起作用.布局具有父颜色.
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:height="60px"
>
<shape
android:shape="rectangle"
android:height="30px"
>
<solid
android:color="#ff297baf"
/>
</shape>
<shape
android:shape="rectangle"
android:height="30px"
>
<gradient
android:type="linear"
android:startColor="#ff297baf"
android:endColor="#ff16c0e3"
android:angle="270"/>
</shape>
<shape
android:shape="rectangle"
android:height="3px"
>
<solid
android:color="#FFFFFFFF"
/>
</shape>
</shape>
Run Code Online (Sandbox Code Playgroud)
我试图用3种颜色制作渐变.从纯色开始#ff297baf,以60%开始渐变#ff297baf,#ff16c0e3然后在末尾添加一条渐变线.
kco*_*ock 10
如果您打算使用多个形状,您应该尝试使用LayerListDrawable.这样的东西对我有用,但仅适用于60px的示例高度.您可能需要对其进行修改以完全满足您的需求,但这应该为您提供一个良好的开端:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:angle="270"
android:endColor="#ff16c0e3"
android:startColor="#ff297baf"
android:type="linear" />
</shape>
</item>
<item android:top="57px">
<shape android:shape="rectangle">
<solid android:color="#FFFFFFFF" />
<size android:height="3px" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)