2

I created an Oval Shape and set the sizes 56px for each height and width. but i had an Oval Shape not a circle! when i set the sizes to 78px for each i get an exact circle! Anyone noticed or faced this issue? Solutions please!

clear_test.xml this gives me an Oval shape! different Height and Width in the layout

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#7caf00"/>
    <size android:width="56px"
        android:height="56px"/>

</shape>

calc_test.xml But this gives an exact circle

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#7caf00"/>
    <size android:width="78px"
        android:height="78px"/>



</shape>
Borzstag
  • 43
  • 5

1 Answers1

0

Shape depends upon the size of your view.The view on which you are setting this shape drawable should have equal sizes

for eg:

<view android:layout_width="56px" android:layout_height="56px" android:background="@drawable/clear_test"/>

Note: You shouldn't use px, always use dp/dip as measurement units.(Above example has "px",so it does match your xml code)

Sreejith B Naick
  • 1,203
  • 7
  • 13
  • It works fine! but i'm supporting multiple screens so i will need bigger shapes for bigger screens! i set height and width wrap_content. and why does it work when the sizes are 78px! weird.. – Borzstag Jul 04 '14 at 05:11
  • what kind of view are you using, imageview,textview ? – Sreejith B Naick Jul 04 '14 at 05:22
  • Since you have to support multiple screen, it's better to set the size of your view by code, because wrap_content may give rect shape instead of square shape – Sreejith B Naick Jul 04 '14 at 05:37