渐变透明背景
Gradient Transparent Background
我想在图像上获得透明渐变,为什么透明度有效:
<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>
所以没有
android:background="@drawable/background_gradient_blue_indigo>//TRANSPARENT NOT WORK
background_gradient_blue_indigo :
<?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_gradient_blue_indigo"
添加到 FrameLayout
。
但是请注意,这会使整个视图透明,而不是背景中的可绘制对象。
我想在图像上获得透明渐变,为什么透明度有效:
<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>
所以没有
android:background="@drawable/background_gradient_blue_indigo>//TRANSPARENT NOT WORK
background_gradient_blue_indigo :
<?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_gradient_blue_indigo"
添加到 FrameLayout
。
但是请注意,这会使整个视图透明,而不是背景中的可绘制对象。