Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android渐变不填充背景_Android_Gradient - Fatal编程技术网

Android渐变不填充背景

Android渐变不填充背景,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

我遇到了渐变背景的麻烦。结果不是我想要的。我不能改变梯度上的任何东西

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="@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>