I am just designing a layout for login. However, I want to set a layout gravity center (full layout content set into the center of the screen). I am using gravity center but it doesn't give me the proper output, So may be I am having problem with another issue. Bellow is my layout xml code. Hence, Can someone suggest me where I am having problem !!!
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="30dp" android:paddingLeft="20dp" android:layout_marginTop="10dp" android:background="#458221" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Hello" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center" <!-- I want to set this layout into the center of the screen ,This layout cann't set the gravity center --> > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="User Name: " /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="user" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="password" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="pass" /> </LinearLayout> </LinearLayout>
No comments:
Post a Comment