Archie.bpgc
Archie.bpgc

Reputation: 24012

Unable to center Text in a button

This is quiet straight forward. But don't know why this isn't working.

This is the Code i have in the xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/one"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal"
        android:paddingBottom="15dp"
        android:background="@drawable/blue9Patch"
        android:paddingTop="12dp"
        android:text="One" />

    <Button
        android:id="@+id/shareProductButton_shareOptions"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal"
        android:paddingBottom="15dp"
        android:background="@drawable/blue9Patch"
        android:paddingTop="12dp"
        android:text="Two" />
</LinearLayout>

This is what i get in the Graphical Layout in Eclipse:

enter image description here

But on the emulator it is like this:

enter image description here

This is the 9-patch image i am using as a Background

enter image description here

Thought, on device it would work fine, but didn't.

I want it to be like the first image.

Thank You.

Upvotes: 0

Views: 143

Answers (1)

Clearly I assume you had used .9Patch image with setting content area i.e. assigning pixels on Right and Bottom part. you just need to clear that assignment or just fill all the Bottom and Right end pixel(padding box). Thats it.

enter image description here

Finally this one

enter image description here

Upvotes: 4

Related Questions