I have a simple layout that only has one EditText
and one TextView
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/lblName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25sp"
android:textStyle="bold" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:id="@+id/txtName"/>
</LinearLayout>
</LinearLayout>
And I want to center the TextView
to the center of the screen of my mobile phone.
I saw that I can replace my LinearLayout
to a RelativeLayout
as global layout and set the property android:gravity="center"
to center it, but I ONLY want to center the TextView
and not the EditText
, which it's also centered with this function.
Is it possible to center just the TextView
without center the EditText
?
Note: Of course, I don't want to center it manually with margins.
EDIT: I want that the TextView will be center on the screen and the EditText will be in the nextLine (on the left of the screen). Something like this:
[ WIDHT OF THE SCREEN ]
[TEXTVIEW-CENTER]
[EDITTEXT-LEFT]
Thanks in advance!