I want to draw something oval with some pointer to something . How can I achieve it via shapes in Android?
Asked
Active
Viewed 501 times
-5
-
I think you can not do it just with **shape drawable** but with custom view and other drawable you can do it easily. – mmlooloo Oct 09 '14 at 02:57
-
The obvious and the easy way is you use a drawable resource.. – karvoynistas Oct 09 '14 at 13:02
1 Answers
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:
more on ListLayer xml elements here

Akah
- 1,389
- 14
- 19