我写了一个应用程序,它具有相同的效果.我做的是,我创建了一个FrameLayout,其中包含
ImageView和另一个具有相同ImageView高度的View.然后我在视图中添加透明渐变背景.
例:
布局文件:
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@drawable/image"
android:adjustViewBounds="true" />
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="@drawable/gradient" />
绘制/ gradient.xml
android:shape="rectangle">
android:angle="90"
android:endColor="#00ffffff"
android:startColor="#aa000000"
android:centerColor="#00ffffff" />