如何在 android 中为线性布局创建如下所示的阴影效果?
How to create shadow effects just like shown below for linear layout in android?
我想知道是否可以在 android 中为线性布局创建阴影效果,如下所示。
任何帮助将不胜感激...
方法有很多种,这里有适合你的方法
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>
和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"
或:
android:background="@android:drawable/dialog_frame"
或:
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
使用本网站创建9个带阴影的补丁
然后使用 9 补丁图像,
有关更多详细信息,请参阅 shadow LinearLayout
我想知道是否可以在 android 中为线性布局创建阴影效果,如下所示。 任何帮助将不胜感激...
方法有很多种,这里有适合你的方法
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>
和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"
或:
android:background="@android:drawable/dialog_frame"
或:
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
使用本网站创建9个带阴影的补丁
然后使用 9 补丁图像,
有关更多详细信息,请参阅 shadow LinearLayout