How to get a circular shape in a gridview cell in android

I am using gridview to create a simple calculator app. I am using gridView for holding calculator buttons. The gridview is a layout with a TextView. DextView uses a pull-out background that uses an oval shape. Below are the XML views:

Xml grid grid    

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/id_gridCell"
        android:background="@drawable/circularbutton_selector"
        android:layout_margin="0dp"
        android:gravity="center_horizontal|center_vertical"
        android:textSize="40dp"
        android:text="-"
        android:layout_gravity="center_horizontal|center_vertical"
        android:elevation="5dp"
        /> </LinearLayout>

      

Hand drawn shape

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

        <solid android:color="@color/accent_material_dark"/>
        <stroke android:width="2dp" android:color="#AAA"/> </shape>

      

Question: Depending on the width / height of the cell, the shape ends up being oval rather than round. I cannot provide a hard value as the children of the grid must scale to any device. Is there a way to achieve a circle that scales with the dimensions of the device? The idea is to get the scale as the margins change.

+3
android android-gridview gridview


source to share


No one has answered this question yet

Check out similar questions:

3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
2510
How to persist android activity state by persisting instance state?
1270
How to pass data between activities in an Android app?
1188
How do I get the build / version number of your Android app?
1039
Get current time and date on Android
1002
How do I display an alert dialog on Android?
960
How to rotate the screen of Android emulator?
882
Static way to get "Context" in Android?
620
How to define circle shape in rendered android xml file?
4
Android GridView 3 x 6 Cropping Images



All Articles
Loading...
X
Show
Funny
Dev
Pics