Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : How to create oval size drawable resouce?

I am trying to create drawable resource oval com rectangle shape? I want exact the below shape enter image description here

But I am getting the follow :

enter image description here

what I'm using:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle" >

  <gradient
    android:startColor="#36D53D"
    android:centerColor="#36D53D"
    android:endColor="#36D53D"
    android:angle="90"/>
  <padding android:left="3dp"
    android:top="5dp"
    android:right="5dp"
    android:bottom="5dp" />

  <corners android:radius="160dp"></corners>
</shape>

how to create the shape what I want? Thank you in advance

like image 630
Aristo Michael Avatar asked Oct 25 '25 04:10

Aristo Michael


2 Answers

Try this one for oval.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >

    <!-- fill/color -->
    <solid
        android:color="#ff0000"/>

    <!-- Control the width and height of the shape -->
    <size
        android:width="120dp"
        android:height="70dp"/>
</shape>

Rectangle with rounded corner

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

    <!-- fill/color -->
    <solid
        android:color="#ff0000"/>

    <!-- Control the width and height of the shape -->
    <size
        android:width="200dp"
        android:height="70dp"/>

    <!-- Control the radius of each corners -->
    <corners
        android:topLeftRadius="30dp"
        android:topRightRadius="15dp"
        android:bottomLeftRadius="15dp"
        android:bottomRightRadius="15dp"/>
</shape>
like image 152
Ariel Magbanua Avatar answered Oct 27 '25 16:10

Ariel Magbanua


Try this:

<?xml version="1.0" encoding="utf-8"?>

  <shape xmlns:android="http://schemas.android.com/apk/res/android">
      <solid android:color="#189B5F" />
      <corners
          android:topLeftRadius="15dp"
          android:topRightRadius="15dp"
          android:bottomLeftRadius="15dp"
          android:bottomRightRadius="15dp"
          />
  </shape>
like image 35
Mohammad Arman Avatar answered Oct 27 '25 18:10

Mohammad Arman