-5

I want to draw something oval with some pointer to something . How can I achieve it via shapes in Android?

enter image description here

jww
  • 97,681
  • 90
  • 411
  • 885
LearningBasics
  • 660
  • 1
  • 7
  • 24

1 Answers1

0

if i were to do something like this, i would use the 9patch draw tool provided with the IDE. However, in XML i would define a drawable resource that could contain code like this:

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

<item>
    <shape android:shape="rectangle">
        <size 
            android:width="100dp"
            android:height="100dp" />
        <solid android:color="#5EB888" />
        <corners android:radius="0dp"/>
    </shape>
</item>
<!-- default color for item at the top 5EB888 --> 
<item
    android:top="-40dp"
    android:bottom="65dp"
    android:right="-30dp">
    <rotate
        android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>

<item
    android:top="65dp"
    android:bottom="-40dp"
    android:right="-30dp">
    <rotate
        android:fromDegrees="-45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>

</layer-list>

Just apply this drawable as the background to a widget and you will get a pointed rectangle. In your case, you need an oval. You can just switch shapes and adjust sizes to your taste. Hope this helps. The result you get with this code after applying it to a button widget look like this: pointed shape

more on ListLayer xml elements here

Akah
  • 1,389
  • 14
  • 19