我想在图像上获得透明渐变,为什么透明会起作用:
<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
背景渐变蓝色靛蓝:
<?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
。
但是,请注意,这将使整个 View 透明,而不是背景中的可绘制对象。
关于android - 渐变透明背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52514816/