Add shadows at the bottom of image

我怕爱的太早我们不能终老 提交于 2021-02-07 07:22:15

问题


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.

Image


回答1:


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.

Example:

Layout file:

<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>




回答2:


You can use a png image with the gradient color and alpha, put it just at the bottom of the banner image. And your name text is upon the image.



来源:https://stackoverflow.com/questions/31959829/add-shadows-at-the-bottom-of-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!