为图像视图添加渐变 [英] Add gradient to imageview
本文介绍了为图像视图添加渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在图像底部添加渐变.像这样:
I want to add a gradient on the bottom of my image . Something like this :
我试过这样的东西,但我只得到渐变没有图像..
I tried something like this but I only get the gradient no image..
<ImageView
android:id="@+id/trendingImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/trend_donald_sterling"
android:src="@drawable/trending_gradient_shape"
/>
trending_gradient_shape:
trending_gradient_shape:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="@android:color/darker_gray"
android:startColor="@android:color/darker_gray" />
<corners android:radius="0dp" />
</shape>
推荐答案
你需要两层:一个 ImageView
和一个 View
,上面有你的渐变android:background
.将这两个 View
放在一个 FrameLayout
中:
You need two layers: An ImageView
, and a View
on top of that with your gradient as android:background
. Put these two View
s in a FrameLayout
:
<FrameLayout
... >
<ImageView
...
android:src="@drawable/trend_donald_sterling" />
<View
...
android:background="@drawable/trending_gradient_shape"/>
</FrameLayout>
这篇关于为图像视图添加渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文