这是我的xml文件,它在线性布局周围添加边框如何在此代码中添加渐变颜色效果代码?我想用gradiend颜色替换这个颜色#C0C0C0
下面是我的代码
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
<item
android:left="1dp"
android:right="1dp"
android:top="2dp"
android:bottom="2dp" >
<shape android:shape="rectangle">
<solid android:color="#C0C0C0" />
</shape>
</item>
</layer-list>
我想在我的边框.xml文件中添加此代码我如何合并?
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#fefdfe"
android:endColor="#e8e3ec"
android:angle="90" />
</shape>
答案 0 :(得分:1)
用渐变填充布局:
<?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:startColor="#4fc939"
android:centerColor="#0c87c5"
android:endColor="#b4ec51"
android:angle="180" />
</shape>
</item>
答案 1 :(得分:0)
只需替换
<shape android:shape="rectangle">
<solid android:color="#C0C0C0" />
</shape>
带有渐变形状。
答案 2 :(得分:0)
试试这个: -
<shape android:shape="rectangle">
<gradient
android:startColor="#5a5a5a88"
android:endColor="#14141488"
android:angle="270" android:centerX="0.25"/>
</shape>