Reputation: 4590
I'm having an issue trying to do something really simple: Center text in a button/TextView that have a fixed width and height, my text keeps being pushed down as I increase its size, here's a sample of the code I'm using:
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@drawable/circle_add_item"
android:gravity="center"
android:text="+"
android:textColor="@color/green"
android:textSize="75sp" />
Here's an image of what I'm getting as a result:
Would anyone give me a hand ?
Thanks !
Upvotes: 0
Views: 216
Reputation: 1178
Also, you can use this way
<RelativeLayout
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@drawable/circle">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="75sp"
android:layout_marginTop="-20dp"
android:background="@android:color/transparent"
android:text="+"
android:textColor="#00ff00"
android:paddingTop="0dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
Upvotes: 1