Sunday, 7 December 2014

Background programatic drawable cropped



I want to make a button with a letter inside a circle, without using a picture.


My button is defined like this:



<Button
android:id="@+id/zoomInButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:background="@drawable/circle"
android:text="+"
android:textColor="@color/white"
android:textSize="62sp" />

<Button
android:id="@+id/zoomOutButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:background="@drawable/circle"
android:text="-"
android:textColor="@color/white"
android:textSize="62sp" />


And with circle being:



<stroke
android:width="3dp"
android:color="@color/white" />

<solid android:color="@android:color/transparent" />


However, the circle is not centred and the text is cropped:


bad circle


How to center the background on the text?


No comments:

Post a Comment