Android LinearLayout : Add border with shadow around a LinearLayout
Try this..
<?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="#CABBBBBB"/>
<corners android:radius="2dp" />
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="2dp" />
</shape>
</item>
</layer-list>
How to show shadow around the linearlayout in Android?
There is no such attribute in Android, to show a shadow. But possible ways to do it are:
Add a plain LinearLayout with grey color, over which add your actual layout, with margin at bottom and right equal to 1 or 2 dp
Have a 9-patch image with a shadow and set it as the background to your Linear layout
How to create shadow effects just like shown below for linear layout in android?
Then Use 9 Patch image for that,
9 patch image
for more detail here is question for shadow LinearLayout
Add shadow to bottom of view
Try using below line in the linearlayout
under which your cardview
is sitting.
android:elevation="8dp"
Let the cardElevation
part in your cardView
be as it is.
card_view:cardElevation="10dp"
card_view:cardPreventCornerOverlap="false"
Also just a suggestion :
If you're using android:layout_weight
in both child linearLayout
put android:weightSum="2"
in your parent linearLayout
as mentioned in answer given by @Ming Leung here
For more information on android:weightSum="2"
you can refer to answers on this page
This page would help you for elevation
in cardview
Hope that helps.
Related Topics
How to Handle Multiple Countdown Timers in Listview
Rotating a Bitmap Using Jni & Ndk
Libpng Error: Not a Png File Error Showing in Android Studio
How to Keep an Alertdialog Open After Button Onclick Is Fired
Mobile Vision API - Concatenate New Detector Object to Continue Frame Processing
Return Value from Asynctask Class Onpostexecute Method
How to Pass Bundle from Fragment to Fragment
How to Save Scroll Position of Recyclerview in Android
Filter Listview with Arrayadapter
Cmusphinx Pocketsphinx - Recognize All (Or Large Amount) of Words
Create New Project on Android, Error: Studio Unknown Host 'Services.Gradle.Org'
Class Java.Util.Map Has Generic Type Parameters, Please Use Generictypeindicator Instead
Datepicker Shows Wrong Value of Month
How to Change Action Bar Title Color in Code
How to Get Contacts' Phone Number in Android
Android: Unable to Instantiate Activity/Classnotfoundexception