android - How to set LinearLayout at center of it's parent RelativeLayout -
hi new android , in login page have 2 linearlayouts second linear-layout want set @ center of it's parent relative- layout , linear layout want set top|left of it's parent relative- layout
please me one
code:-
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rootlayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/yellow"> <scrollview android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="false"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:gravity="top" android:layout_alignparentleft="true" android:orientation="vertical"> <textview android:id="@+id/user_name_text_view_id" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:text="@string/language_title" android:textappearance="?android:attr/textappearancemedium" android:textcolor="@color/redcolor" /> <spinner android:id="@+id/spinnerlist" style="@style/spinner_style" android:layout_width="85dp" android:layout_height="wrap_content" android:layout_margintop="3dp" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="40dp" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_margintop="25dp" android:src="@drawable/ic_serba_logo_red" /> </relativelayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:id="@+id/textmain" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:layout_margin="10dp" android:orientation="vertical"> <edittext android:id="@+id/edittext1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="@drawable/bordertextbox" android:ems="10" android:hint="@string/username_title" android:inputtype="textemailaddress" android:padding="8dp" android:textcolor="@android:color/white" android:textcolorhint="@android:color/white"> <requestfocus /> </edittext> <edittext android:id="@+id/edittext2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="10dp" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:layout_margintop="7dp" android:background="@drawable/bordertextbox" android:ems="10" android:hint="@string/password_title" android:inputtype="textpassword" android:padding="8dp" android:textcolor="@android:color/white" android:textcolorhint="@android:color/white" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:weightsum="2"> <button android:id="@+id/registerbutton" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginright="7dp" android:layout_weight="1" android:background="@color/splahbgcolor" android:text="@string/user_register_title" android:textcolor="@android:color/white" /> <button android:id="@+id/loginbutton" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginleft="7dp" android:layout_weight="1" android:background="@color/splahbgcolor" android:text="@string/user_login__title" android:textcolor="@android:color/white" /> </linearlayout> </linearlayout> </relativelayout> </linearlayout> </linearlayout> </relativelayout> </scrollview> </relativelayout>
you need change 2 things :
android:fillviewport="true" //for scrollview
and relativelayout
height should match_parent
android:layout_height="match_parent"
Comments
Post a Comment