design - Android: layout alignment on different screen sizes -


i have created button , edittext on relative layout. centered align objects i've made on nexus s screen doesn't intended on other screen sizes.

this code , image link http://flic.kr/p/fuygdf dont have 10 reputation points post images:

    <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin"   android:background= "@drawable/chalk" tools:context=".mainactivity" >  <button     android:id="@+id/button1"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/password"     android:layout_alignparentbottom="true"     android:layout_marginbottom="80dp"     android:background="@android:color/transparent"     android:gravity="center"     android:onclick="login"     android:text="login"     android:textstyle="bold" />  <edittext     android:id="@+id/password"     android:layout_width="300dp"     android:layout_height="100dp"     android:layout_above="@+id/button1"     android:layout_alignleft="@+id/username"     android:layout_marginbottom="40dp"     android:layout_weight="0.03"     android:background = "@android:color/transparent"     android:ems="10"     android:gravity="center"     android:hint="password"     android:inputtype="textpassword"     android:singleline="true" />  <edittext     android:id="@+id/username"     android:layout_width="300dp"     android:layout_height="90dp"     android:layout_alignbottom="@+id/password"         android:background = "@android:color/transparent"     android:layout_centerhorizontal="true"     android:layout_marginbottom="78dp"     android:layout_weight="10.04"     android:ems="10"     android:gravity="center"     android:hint="username"     android:singleline="true" >      <requestfocus /> </edittext> 

so basically, want make them center aligned in screen. how can this?

try this::

i have used code in app , working great.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"   xmlns:tools="http://schemas.android.com/tools"      android:id="@+id/linearlayout1"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_centerinparent="true"     android:gravity="center"     android:orientation="vertical"     android:paddingtop="20dp"     android:paddingleft="20dp"     android:paddingright="20dp"     android:paddingbottom="10dp" >       <edittext         android:id="@+id/etemail"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:ems="10"         android:hint="email"         android:inputtype="textemailaddress"         android:layout_margintop="10dp" >          <requestfocus />     </edittext>      <edittext         android:id="@+id/etpassword"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:ems="10"         android:hint="password"         android:inputtype="textpassword" />      <button     android:id="@+id/btnsend"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="center"     android:layout_margintop="10dp"     android:text="login" /> </linearlayout> 

hope helps!!


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -