在图像底部添加阴影 [英] Add shadows at the bottom of image

查看:62
本文介绍了在图像底部添加阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在图像上方(底部右侧)添加阴影,以使标题清晰可见.参见下图.

How can I add a shadow over the image (right at the bottom) in order to have the title to be clearly visible. See the image below.

推荐答案

我编写了一个具有相同效果的应用程序.我所做的是,创建了一个 FrameLayout ,该框架具有 ImageView 和另一个具有与ImageView相同高度的 View .然后,将透明的渐变背景添加到视图.

I wrote an application, which has the same effect. What I did is, I created a FrameLayout which has the ImageView and another View which has the same height of the ImageView. Then I add a transparent gradient background to the View.

示例:

布局文件:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:src="@drawable/image"
        android:adjustViewBounds="true" />

    <View
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:background="@drawable/gradient" />

</FrameLayout>

drawable/gradient.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient
        android:angle="90"
        android:endColor="#00ffffff"
        android:startColor="#aa000000"
        android:centerColor="#00ffffff" />
</shape>

这篇关于在图像底部添加阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆