How to create shadow effects just like shown below for linear layout in android? [closed]

你离开我真会死。 提交于 2021-02-07 04:34:04

问题


I was wondering if it's possible to create shadow effect for linear layout in android just like shown below. Any help would be appreciated...


回答1:


Then Use 9 Patch image for that,

9 patch image

for more detail here is question for shadow LinearLayout




回答2:


There are lots of ways and here they are Use that which one suits you

Create your own drawable

border.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape
            android:shape="rectangle">
            <solid android:color="@android:color/darker_gray" />
            <corners android:radius="5dp"/>
        </shape>
    </item>
    <item android:right="1dp" android:left="1dp" android:bottom="2dp">
        <shape
            android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="5dp"/>
        </shape>
    </item>
</layer-list>

and your_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="horizontal"
   android:padding="10dp"
   android:background="@drawable/border"
  >
</LinearLayout>

You can also use use a drawable from android

android:background="@android:drawable/toast_frame"

or:

android:background="@android:drawable/dialog_frame"

or:

android:background="@android:drawable/dialog_holo_light_frame"

Use a 9-patch image with a shadow and set it as the background to your Linear layout

Use this website to create 9 patch with shadow

http://inloop.github.io/shadow4android/



来源:https://stackoverflow.com/questions/34984949/how-to-create-shadow-effects-just-like-shown-below-for-linear-layout-in-android

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