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
source to share
No one has answered this question yet
Check out similar questions: