Antzi
Antzi

Reputation: 13414

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:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >

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

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

</shape>

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

bad circle

How to center the background on the text?

Upvotes: 0

Views: 85

Answers (1)

Kaushik
Kaushik

Reputation: 6162

Try to reduce textSize of those Buttons' because there is not enough room for 62sp thats why the texts are cropped.

Upvotes: 1

Related Questions