How to add Shadow effect to a Framelayout?

Asked

Viewed 122 times

0

I’d like to add an effect shadow which results in a bounce of the screen, like this below:

Google image:

Google

Code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@color/gray">


    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/imageView_header_book"
            android:layout_width= "match_parent"
            android:layout_height="84dp"
            android:layout_marginBottom="410dp"
            android:scaleType="fitXY"
            android:src="@drawable/header_book"/>

        <TextView
            android:id="@+id/custom_view_loja"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:gravity="center_horizontal|center_vertical"
            android:maxLines="1"
            android:textColor="@color/white"
            android:textSize="@dimen/overlay_loja"
            android:textStyle="bold"
            android:shadowColor="@color/black"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="2"/>

        <TextView
            android:id="@+id/custom_view_shopping"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:gravity="center_horizontal|center_vertical"
            android:shadowColor="@color/black"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="2"
            android:maxLines="1"
            android:textColor="@color/white"
            android:textSize="@dimen/overlay_shopping" />

        <TextView
            android:id="@+id/custom_view_competencia"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="71dp"
            android:gravity="center_horizontal|center_vertical"
            android:maxLines="1"
            android:textColor="@color/white"
            android:textSize="@dimen/overlay_competencia"
            android:shadowColor="@color/black"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="2"/>
    </FrameLayout>

    <LinearLayout
        android:id="@+id/custom_view_information_container"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/custom_view_book_horizontal"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:orientation="horizontal" >

            <LinearLayout
                android:id="@+id/custom_view_book_text_data"
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:orientation="vertical">

                <FrameLayout
                    android:layout_width="245dp"
                    android:layout_height="60dp"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:layout_marginTop="88dp"
                    android:background="@color/white">

                    <ImageView
                        android:id="@+id/imageView_aluguel_shopping"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_gravity="left"
                        android:layout_marginLeft="15dp"
                        android:layout_marginTop="6dp"
                        android:src="@drawable/aluguel_shopping" />

                    <TextView
                        android:id="@+id/textView_aluguel_icon_title"
                        android:layout_width="wrap_content"
                        android:layout_height="14dp"
                        android:layout_gravity="left"
                        android:layout_marginLeft="75dp"
                        android:layout_marginTop="17dp"
                        android:gravity="left"
                        android:text="Aluguel"
                        android:textColor="@color/black"
                        android:textSize="@dimen/overlay_aluguel_icon"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/custom_view_valor_aluguel"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:layout_gravity="left"
                        android:layout_marginLeft="73dp"
                        android:layout_marginTop="30dp"
                        android:gravity="left"
                        android:maxLines="1"
                        android:textColor="@color/green_aliansce"
                        android:textSize="@dimen/overlay_valorAluguel" />

                    <ImageView
                        android:id="@+id/imageView_aluguel_mensal_icon"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal|center_vertical"
                        android:layout_marginBottom="6dp"
                        android:layout_marginLeft="32dp"
                        android:src="@android:drawable/presence_online" />

                    <TextView
                        android:id="@+id/textView_aluguel_mensal_icon_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="18.5dp"
                        android:layout_marginRight="60dp"
                        android:gravity="right"
                        android:text="Mensal"
                        android:textColor="@color/black"
                        android:textSize="8dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/custom_view_valor_aluguelMensal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="28dp"
                        android:layout_marginRight="55dp"
                        android:gravity="right"
                        android:maxLines="1"
                        android:textColor="@color/black"
                        android:textSize="7dp" />

                    <ImageView
                        android:id="@+id/imageView_valor_anual_icon"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal|center_vertical"
                        android:layout_marginBottom="6dp"
                        android:layout_marginLeft="85dp"
                        android:src="@android:drawable/presence_invisible" />

                    <TextView
                        android:id="@+id/textView_aluguel_anual_icon_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="18.5dp"
                        android:layout_marginRight="13dp"
                        android:gravity="right"
                        android:text="Anual"
                        android:textColor="@color/black"
                        android:textSize="8dp"
                        android:textStyle="bold" />


                    <TextView
                        android:id="@+id/custom_view_valor_aluguelAnual"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="28dp"
                        android:layout_marginRight="6dp"
                        android:gravity="right"
                        android:maxLines="1"
                        android:textColor="@color/black"
                        android:textSize="7dp" />
                </FrameLayout>


                <FrameLayout
                    android:layout_width="245dp"
                    android:layout_height="60dp"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:layout_marginTop="4dp"
                    android:background="@color/white">

                    <ImageView
                        android:id="@+id/imageView_venda_shopping"
                        android:layout_width="40dp"
                        android:layout_height="50dp"
                        android:layout_gravity="left"
                        android:layout_marginLeft="20dp"
                        android:layout_marginTop="6dp"
                        android:src="@drawable/venda_shopping" />

                    <TextView
                        android:id="@+id/textView_vendas_icon_title"
                        android:layout_width="wrap_content"
                        android:layout_height="14dp"
                        android:layout_gravity="left"
                        android:layout_marginTop="17dp"
                        android:layout_marginLeft="75dp"
                        android:gravity="left"
                        android:text="Venda"
                        android:textColor="@color/black"
                        android:textSize="@dimen/overlay_venda_icon"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/custom_view_valor_venda"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:layout_gravity="left"
                        android:layout_marginTop="30dp"
                        android:layout_marginLeft="70dp"
                        android:gravity="left"
                        android:maxLines="1"
                        android:textColor="@color/green_aliansce"
                        android:textSize="@dimen/overlay_valorVenda"
                        android:textStyle="bold" />

                    <ImageView
                        android:id="@+id/imageView_venda_mensal_icon"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal|center_vertical"
                        android:layout_marginBottom="6dp"
                        android:layout_marginLeft="32dp"
                        android:src="@android:drawable/presence_online" />

                    <TextView
                        android:id="@+id/textView_venda_mensal_icon_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="18.5dp"
                        android:layout_marginRight="60dp"
                        android:gravity="right"
                        android:text="Mensal"
                        android:textColor="@color/black"
                        android:textSize="8dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/custom_view_valor_vendaMensal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="28dp"
                        android:layout_marginRight="55dp"
                        android:gravity="right"
                        android:maxLines="1"
                        android:textColor="@color/black"
                        android:textSize="8sp" />

                    <ImageView
                        android:id="@+id/imageView_venda_anual_icon"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal|center_vertical"
                        android:layout_marginBottom="6dp"
                        android:layout_marginLeft="85dp"
                        android:src="@android:drawable/presence_invisible" />

                    <TextView
                        android:id="@+id/textView_venda_anual_icon_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="18.5dp"
                        android:layout_marginRight="13dp"
                        android:gravity="right"
                        android:text="Anual"
                        android:textColor="@color/black"
                        android:textSize="8dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/custom_view_valor_vendaAnual"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:layout_marginTop="28dp"
                        android:layout_marginRight="6dp"
                        android:gravity="right"
                        android:maxLines="1"
                        android:textColor="@color/black"
                        android:textSize="8sp" />

                </FrameLayout>

                <FrameLayout
                    android:layout_width="245dp"
                    android:layout_height="35dp"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:layout_marginTop="4dp"
                    android:background="@color/white">

                    <ImageView
                        android:id="@+id/imageView_custo_ocupacao_shopping"
                        android:layout_width="40dp"
                        android:layout_height="30dp"
                        android:layout_gravity="left"
                        android:layout_marginTop="3dp"
                        android:layout_marginLeft="20dp"
                        android:src="@drawable/ocupacao_shopping" />

                    <TextView
                        android:id="@+id/textView_custo_ocupacao_icon_title1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="left"
                        android:layout_marginTop="5dp"
                        android:layout_marginLeft="75dp"
                        android:gravity="left"
                        android:text="Custo"
                        android:textColor="@color/black"
                        android:textSize="@dimen/overlay_venda_icon"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textView_custo_ocupacao_icon_title2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="left"
                        android:layout_marginTop="14dp"
                        android:layout_marginLeft="75dp"
                        android:gravity="left"
                        android:text="Ocupação"
                        android:textColor="@color/black"
                        android:textSize="@dimen/overlay_venda_icon"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/badge_custoOcupacao_valor"


            android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_gravity="left"
                    android:layout_marginTop="30dp"
                    android:layout_marginLeft="85dp"
                    android:gravity="left"
                    android:maxLines="1"
                    android:textSize="11sp"
                    android:textStyle="bold" />


            </FrameLayout>

        </LinearLayout>
    </LinearLayout>
</LinearLayout>

  • Thiago, avoid using citation formatting near code without being necessary as the code will need 8 spaces to stand out.

1 answer

1


You can add lift to his FrameLayout. Behold:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:elevation="4dp"
    android:translationZ="4dp">

Note: The elevation is available from v21 Android.

PS.: later I come back here and I complete this answer

  • I have tried to use these two commands in Framelayout and even tried to increase their values, but nothing happens. What will be?

  • 1

    You need to put a padding on the external layout of Framelayout and add in this same layout an android:clipToPadding="false"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.