I would like to create the same border of this LinearLayout as the example :
In this example, we can see that the border is not the same all around the linearLayout. How can I create this using an XML drawable file?
For now, I have only able to create a simple border all around the LinearLayout like this :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:radius="1dp"
android:topRightRadius="0dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp" />
<stroke
android:width="1dp"
android:color="#E3E3E1" />
<solid android:color="@color/blanc" />
</shape>
Use this single line and hopefully you will achieve the best result;
use:
android:elevation="3dp"
Adjust the size as much as you need and this is the best and simplest way to achieve the shadow like buttons and other default android shadows. Let me know if it worked!That's why CardView exists. CardView | Android Developers
It's just a FrameLayout that supports elevation in pre-lollipop devices.
To use this you need to add dependency to
build.gradle
:You can generate a shadow with this site: http://inloop.github.io/shadow4android/. Set parameters and download 9-patch.png file.
You can do it with 9 patch graphic, but it is wrong way, because you have to use png file. I think you should use xml file (drawable file). Try use this code
gradient_top.xml
gradient_left.xml
gradient_right.xml
gradient_bottom.xml
You create a file .xml in drawable with name drop_shadow.xml:
Then: