Android渐变不填充背景
我遇到了渐变背景的麻烦。结果不是我想要的。我不能改变梯度上的任何东西 shadow.xmlAndroid渐变不填充背景,android,gradient,Android,Gradient,我遇到了渐变背景的麻烦。结果不是我想要的。我不能改变梯度上的任何东西 shadow.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="0" android:endColor="@c
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="0"
android:endColor="@color/holo_orange_dark"
android:startColor="@color/holo_green_dark" />
</shape>
color.xml
<color name="holo_green_dark">#ff669900</color>
<color name="holo_orange_dark">#ffff8800</color>
#ff669900
#FF8800
item.xml
<View
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_alignBottom="@+id/term"
android:layout_alignLeft="@+id/term"
android:background="@drawable/shadow"
/>
每种颜色都是黑白相间的。问题是什么?将您的视图背景从
android:background=“@drawable/shadow”
更改为android:background=“@drawable/gradient”
,正如您提到的gradient.xml使用以下代码为视图或布局应用渐变
activity_main.xml:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/gradient_transparent"/>
gradient_transparent.xml(res/drawable):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#000000"
android:centerColor="#7f000000"
android:endColor="#0f000000"
android:angle="90"
android:dither="true"
/>
</shape>