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>