How would I achieve a shape like below in Android, through an Android shape drawable:
Asked
Active
Viewed 849 times
1
-
I can't believe this question is so well received.. Usually questions like this gets downvoted because the lack of effort and info given by OP. – HB. Nov 10 '17 at 18:55
-
1You're right, sorry, this was my first question and i was just testing the platform, I decided to erase it because I really had the answer, but someone had already commented, so I decided to simply accept their response. – wilsonrc Nov 10 '17 at 19:46
2 Answers
3
You can simply create a custom shape and set it as background to your TextView
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00ff00" />
<corners
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp" />
</shape>
You can acchieve the shadow by just setting the elevation attribute on your TextView
(or wrap it in a CardView
and set the elevation tehre if you are using an older version of Android)

Katharina
- 1,612
- 15
- 27
1
You can make a XML drawable file like the one provided below and then put android:background="@drawable/my_bg.xml"
in your textview.
Example: my_bg.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#EF4836"/>
<stroke android:width="0dp"
android:color="@android:color/transparent"
/>
<padding android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<corners android:bottomRightRadius="4dp" android:bottomLeftRadius="0dp"
android:topLeftRadius="4dp" android:topRightRadius="0dp"/>
</shape>

Lukingan
- 84
- 7