textview - How to RelativeLayout Align Center android -



textview - How to RelativeLayout Align Center android -

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_marginleft="78dp" android:layout_margintop="199dp" android:text="test" /> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textview1" android:text="i want align center" /> </relativelayout>

here xml code.

i want utilize layout_aligncenter="@+id/textview1" in textview2.

but there no aligncenter.

i think layout_centervertical or centerinparent useless.

you wanted show text view exact center of screen....then utilize below modified code.

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:layout_centerinparent="true" android:text="test" /> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textview1" android:text="i want align center" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:layout_centerinparent="true"/> </relativelayout>

this work you. if there other requirement explain in detail.

android textview relativelayout

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -