java - How to set the same Button size and label for our screen in android -


am try fit buttons, textviews etc., in relative layout.and using header , footer linear layout(vertical). screen looks diff. in tablet device, , looks diff. in mobile device why?

coding xml:

<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:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" >  <linearlayout     android:id="@+id/linearlayout1"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparenttop="true"     android:layout_centerhorizontal="true"     android:layout_margintop="26dp"     android:orientation="vertical" >      <textview         android:id="@+id/textview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:text="header part" /> </linearlayout>  <linearlayout     android:id="@+id/linearlayout2"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:layout_alignright="@+id/linearlayout1"     android:orientation="vertical" >      <textview         android:id="@+id/textview2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:layout_marginleft="61dp"         android:layout_margintop="79dp"         android:text="footer part" /> </linearlayout>  <textview     android:id="@+id/textview3"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/linearlayout1"     android:layout_below="@+id/linearlayout1"     android:layout_marginleft="26dp"     android:layout_margintop="65dp"     android:text="name" />  <textview     android:id="@+id/textview4"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/textview3"     android:layout_below="@+id/textview3"     android:layout_margintop="47dp"     android:text="password" />  <edittext     android:id="@+id/edittext1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_aligntop="@+id/textview3"     android:layout_marginleft="19dp"     android:layout_torightof="@+id/textview4"     android:ems="10"     android:inputtype="textpersonname" > </edittext>  <edittext     android:id="@+id/edittext2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/edittext1"     android:layout_aligntop="@+id/textview4"     android:layout_toleftof="@+id/button2"     android:ems="10"     android:inputtype="textpassword" />  <button     android:id="@+id/button1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_above="@+id/linearlayout2"     android:layout_alignleft="@+id/textview4"     android:layout_marginbottom="36dp"     android:text="submit" />  <button     android:id="@+id/button2"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbaseline="@+id/button1"     android:layout_alignbottom="@+id/button1"     android:layout_alignright="@+id/linearlayout2"     android:layout_marginright="48dp"     android:text="cancel" /> 

if want set screen orientation:

setrequestedorientation (activityinfo.screen_orientation_portrait); 

put above code after setcontentview(r.layout.activity_main);

you see more options other screen_orientation_portrait there. looking @ question headline , description find confused.

you need read wrap_content, fill_parent , match_parent attributes in xml layout file. learn more how screen size of screen. there many tutorials same available online.

you can check out sites vogella or android hive.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -