Skip to content Skip to sidebar Skip to footer

Center Horizontally And/or Vertically With 9 Patch In Android

I can't find a topic talking about my problem which seems to me standard ... And that make me think it is not possible. But I give a try. I have a RelativeLayout with a 9 patch bac

Solution 1:

this layout file will do the task

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@drawable/background"android:gravity="center" ><TextViewandroid:id="@+id/txtTest"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Test TextView"android:textColor="#000000" ></TextView></RelativeLayout>

the 9-patch image i used is

enter image description here

Post a Comment for "Center Horizontally And/or Vertically With 9 Patch In Android"