类似于LinearGradient 实现一张Imageview的alpha值从上到下增大或减小的效果
3条回答 默认 最新
- 战在春秋 2017-06-01 08:40关注
在Imageview上面加一个view,然后将Imageview和view放到同一个Frameout布局中。
结构如下:<FrameLayout ... > <ImageView ... android:src="@drawable/img_sample" /> <View ... android:background="@drawable/gradient_shape"/> </FrameLayout>
其中 :
img_sample是res/drawable/ 的图片。
res/drawable/gradient_shape.xml文件如下:<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#00FFFFFF" //前面两位00代表alpha android:endColor="#FFFFFFFF" android:type="linear" /> </shape>
基本方法就是这样,你可以根据自己想要的效果细调。
用心回答每个问题,如果有帮助,请采纳答案好吗,谢谢~~~
解决 无用评论 打赏 举报