Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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_Background_Gradient - Fatal编程技术网

Android 梯度透明背景

Android 梯度透明背景,android,background,gradient,Android,Background,Gradient,我想在图像上获得一个透明的渐变,为什么透明可以工作: <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content"> <com.twick.screens.custom.SquaredImageView android:id="@+id/rv_image" a

我想在图像上获得一个透明的渐变,为什么透明可以工作:

    <android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.twick.screens.custom.SquaredImageView
        android:id="@+id/rv_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/office"/>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#80abcdef" > //TRANSPARENT WORK
    </FrameLayout>

</android.support.v7.widget.CardView>
背景色\渐变色\蓝色\靛蓝:

<?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="#800055FA" //80 transaprent
    android:startColor="#807942DF" //80 transparent/>
</shape>

android:alpha=0.8
(或任何您想要的浮点值)以及
android:background=“@drawable/background\u gradient\u blue\u indigo”
添加到
框架布局中


但是,请注意,这将使整个视图透明,而不是背景中的可绘制视图。

Thx,正常工作!是的,接受了!)这使得整个视图透明,而不仅仅是背景。我同意。在答案中添加了这一点。:)
<?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="#800055FA" //80 transaprent
    android:startColor="#807942DF" //80 transparent/>
</shape>