这是一个简单的问题,但我不知道该怎么做。
渐变有两个部分,结果是这个。
生成的代码是下一个,但我不知道如何将只有一个XML用作背景。
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:centerX="30%"
android:startColor="#00ffffff"
android:centerColor="#FFffffff"
android:endColor="#00ffffff"
android:angle="0"/>
</shape>
-------------------------------------------------
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="radial"
android:centerX="50%"
android:centerY="50%"
android:startColor="#00ffffff"
android:centerColor="#FFffffff"
android:endColor="#00ffffff"
android:gradientRadius="30"/>
</shape>
谢谢
修改:
CODE
<?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:type="linear"
android:centerX="30%"
android:startColor="#00ffffff"
android:centerColor="#FFffffff"
android:endColor="#00ffffff"
android:angle="0"/>
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<gradient
android:type="radial"
android:centerX="50%"
android:centerY="50%"
android:startColor="#00ffffff"
android:centerColor="#FFffffff"
android:endColor="#00ffffff"
android:gradientRadius="30"/>
</shape>
</item>
</layer-list>
RESULT
答案 0 :(得分:2)
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<gradient
android:type="linear"
android:centerX="30%"
android:startColor="#00ffffff"
android:centerColor="#FFffffff"
android:endColor="#00ffffff"
android:angle="0"/>
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<gradient
android:type="radial"
android:centerX="50%"
android:centerY="50%"
android:startColor="#00ffffff"
android:centerColor="#FFffffff"
android:endColor="#00ffffff"
android:gradientRadius="30"/>
</shape>
</item>
</layer-list>
有关图层列表(和其他)here
的更多信息