Android Layout skewed for different screen sizes -


<?xml version="1.0" encoding="utf-8"?> <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"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/layout_blue_border" android:weightsum="1">  <linearlayout     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:weightsum="5"     android:layout_weight="1.5"     android:layout_margin="@dimen/abc_button_inset_horizontal_material"     android:outlineprovider="none">      <linearlayout         android:orientation="horizontal"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_weight="1"         android:id="@+id/textview2"         android:layout_marginleft="@dimen/abc_control_inset_material">          <textview             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:text="moisture probe info"             android:id="@+id/textview9"             android:layout_weight="1"             android:layout_margintop="@dimen/activity_horizontal_margin"             android:textsize="@dimen/abc_text_size_button_material"             android:textstyle="bold" />     </linearlayout>      <tablelayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:outlineprovider="none"         android:orientation="horizontal"         android:layout_below="@+id/actvcal"         android:layout_alignleft="@+id/display_tv"         android:layout_alignstart="@+id/display_tv"         android:weightsum="5"         android:layout_weight="0" >          <linearlayout             android:orientation="horizontal"             android:layout_width="fill_parent"             android:layout_height="match_parent"             android:weightsum="2"             android:layout_weight="1"             android:layout_margin="@dimen/activity_horizontal_margin" >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="serial #:"                 android:id="@+id/serial"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/serial_val"                 android:layout_column="8"                 android:layout_weight="1" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:weightsum="2"             android:layout_margin="@dimen/activity_horizontal_margin" >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="battery:"                 android:id="@+id/battery"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/battery_val"                 android:layout_column="8"                 android:text="0"                 android:layout_alignparentend="true"                 android:layout_weight="1"                 android:layout_alignparentright="true" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:weightsum="2"             android:layout_margin="@dimen/activity_horizontal_margin" >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="firmware ver:"                 android:id="@+id/firmware"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/firmware_val"                 android:layout_column="8"                 android:layout_weight="1" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:weightsum="2"             android:layout_margin="@dimen/activity_horizontal_margin" >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="date:"                 android:id="@+id/date"                 android:textisselectable="false"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/date_val"                 android:layout_column="8"                 android:layout_alignparentend="true"                 android:layout_weight="1"                 android:layout_alignparentright="true" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:weightsum="2"             android:layout_margin="@dimen/activity_horizontal_margin" >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="mac addr:"                 android:id="@+id/macaddr"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/mac_val"                 android:layout_column="8"                 android:layout_weight="1" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_marginleft="@dimen/activity_horizontal_margin"             android:layout_margintop="@dimen/activity_horizontal_margin"             android:layout_marginright="@dimen/activity_horizontal_margin">              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="latitude"                 android:id="@+id/long_text"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/latitude_val"                 android:layout_column="8"                 android:layout_weight="1" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_marginleft="@dimen/activity_horizontal_margin"             android:layout_marginright="@dimen/activity_horizontal_margin"  android:layout_marginbottom="@dimen/activity_horizontal_margin">              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="longitude"                 android:id="@+id/textview3"                 android:layout_weight="1" />              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/longitude_val"                 android:layout_column="8"                 android:layout_weight="1" />         </linearlayout>          <linearlayout             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_margin="@dimen/activity_horizontal_margin" >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:id="@+id/note"                 android:layout_column="8"                 android:layout_weight="1" />         </linearlayout>     </tablelayout>     <linearlayout         android:orientation="horizontal"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:weightsum="3"         android:layout_gravity="bottom"          android:gravity="bottom|fill_vertical"         android:layout_weight=".5"         android:layout_marginleft="@dimen/activity_horizontal_margin">            <textview             android:layout_width="match_parent"             android:layout_height="match_parent"             android:id="@+id/button2"             android:layout_alignparentbottom="true"             android:layout_toleftof="@+id/return2"             android:layout_tostartof="@+id/return2"             android:layout_aligntop="@+id/button1"              android:layout_weight="1"             android:layout_gravity="center_vertical"              android:layout_marginright="@dimen/activity_horizontal_margin"             android:outlineprovider="none" />          <textview             android:layout_width="match_parent"             android:layout_height="match_parent"             android:text=""             android:id="@+id/button1"             android:layout_alignparentend="false"             android:layout_alignparentright="false"              android:layout_weight="1"              android:layout_marginright="@dimen/activity_horizontal_margin"             android:outlineprovider="none" />          <button             android:id="@+id/return2"             android:text="return main menu"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_alignparentbottom="true"             android:layout_alignparentright="true"             android:layout_alignparentend="true"             android:layout_aligntop="@+id/button2"             android:background="@drawable/button_shape_grey"             android:layout_weight="1"              android:textsize="@dimen/abc_text_size_caption_material"             android:layout_marginright="@dimen/activity_horizontal_margin"            />     </linearlayout> </linearlayout>  </linearlayout>  <progressbar     android:id="@+id/progressbar1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_centerhorizontal="true"     android:indeterminate="false"     android:layout_weight=".1"     android:layout_margintop="@dimen/activity_horizontal_margin"     android:layout_gravity="top|center_horizontal" /> </relativelayout> 

i new android programming. layout appears correctly on devices , cut off on others. have added margins "@dimen/activity_horizontal_margin" in xml layout. expected calculated according screen size not case. how can mention margin calculated according available space?

at first, not have many wrapped layouts 1 in another. , second, bad use weight in these cases android need lot of time count value inside deepest component.

in way need better use tablelayout same purposes.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -