I'm trying to create a half oval shaped button, which was easy in the mockup but I found it to be quite difficult doing in the XML file. Also I would like the ripple effect to be constrained only to the oval. There may be a way to cut an oval in the shape XML file that I am not aware of.
What I'm trying to achieve:
But the closest I got is:
Using the following code:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#8C9AEE"/>
<size
android:width="120dp"
android:height="60dp"/>
<corners
android:topLeftRadius="140dp"
android:topRightRadius="140dp"/>
</shape>
Any advice would be appreciated. Non of the options I saw achieved the desired result.
Try the following code
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#8C9AEE" />
<size
android:width="120dp"
android:height="60dp" />
</shape>
or
see the following resource
Hope you helpful!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.