Home » Android » java – how to fix this code all the android screens

java – how to fix this code all the android screens

Posted by: admin June 15, 2020 Leave a comment

Questions:

enter image description here below code I wrote for android but this design is not fitting all the android screens

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
>
<LinearLayout
android:id="@+id/layout_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/wight"
android:baselineAligned="false"
android:orientation="vertical" >
<TextView
android:id="@+id/tseriesname"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:layout_margin="5dp"
android:gravity="center"
android:singleLine="true"
android:text="@string/series_name"
android:textColor="@color/textgraycolor"
android:textSize="10.0sp"
android:textStyle="bold" />
<Button
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:background="@drawable/list_border_back_red"
android:text="Live"
android:textColor="@android:color/white"
android:textSize="15.0sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_match"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/layout_status"
android:layout_weight="0.14"
android:background="@color/wight"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp" >
<LinearLayout
android:layout_width="65dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="@+id/flag_team1"
android:layout_width="65dp"
android:layout_height="65dp"
android:src="@drawable/flag1" />
<TextView
android:id="@+id/team_name1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:text="KKR"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_score_team1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.32"
android:background="@color/wight"
android:baselineAligned="true"
android:orientation="vertical" >
<TextView
android:id="@+id/score_team1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="left|center_vertical"
android:text="160/3"
android:textColor="@color/txtscore"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="@+id/over_tem1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="left"
android:text="(ov : 20)"
android:textColor="@color/textgraycolor"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/vs"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="@drawable/vs"
android:gravity="center_horizontal|center_vertical"
android:text="@string/vs"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/layout_score_team2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.32"
android:background="@color/wight"
android:baselineAligned="true"
android:orientation="vertical" >
<TextView
android:id="@+id/score_team2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="right"
android:text="140/2 "
android:textColor="@color/txtscore"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="@+id/over_tem2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="right"
android:text="(ov: 18.3 )"
android:textColor="@color/textgraycolor"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="65dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="@+id/flag_team2"
android:layout_width="65dp"
android:layout_height="65dp"
android:src="@drawable/flag2" />
<TextView
android:id="@+id/team_name2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:text="MI"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_over_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_match"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:layout_weight="0.16"
android:background="@color/wight"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/re_rr"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:background="@android:color/white"
android:gravity="left"
android:text="Required RR : 2.56"
android:textColor="@android:color/black"
android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:id="@+id/cu_rr"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="0.15"
android:background="@android:color/white"
android:gravity="right"
android:text="Current RR: 5.36"
android:textColor="@android:color/black"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_margin="3dp"
android:layout_weight="0.40"
android:background="@color/wight"
android:gravity="center_vertical|center_horizontal"
android:text="OVER 19"
android:textColor="@color/txtscore"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView05"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt4"
android:gravity="center_vertical|center_horizontal"
android:text="4"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView04"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxtw"
android:gravity="center_vertical|center_horizontal"
android:text="W"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView03"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxtb"
android:gravity="center_vertical|center_horizontal"
android:text="NB"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView02"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt6"
android:gravity="center_vertical|center_horizontal"
android:text="6"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView01"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt0"
android:gravity="center_vertical|center_horizontal"
android:text="."
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/o1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt4"
android:gravity="center_vertical|center_horizontal"
android:text="4"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Mubai Indians  needed 91 runs in 9 balls to win. "
android:textColor="@android:color/black"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="@+id/button1"
android:layout_margin="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/layout_over_details"
android:background="@color/txt_full_score"
android:gravity="center"
android:paddingLeft="2dp"
android:text="Full ScoreBoard"
android:textColor="@color/wight"
android:textSize="20sp"
android:textStyle="bold" />
<TableLayout
android:id="@+id/batting_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button1"
android:layout_weight="1"
android:background="@color/txt_full_score"
android:weightSum="1" 
android:layout_margin="10dp">
<TableRow
android:id="@+id/Batting_heading_Row"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.40" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/wight"
android:padding="1dp"
android:paddingLeft="2dp"
android:text="BATTING"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="R"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="B"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="4s"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="6s"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="SR"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/Batting_one_row"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.30" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/wight"
android:padding="1dp"
android:paddingLeft="2dp"
android:text="Aroan Finch"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="30"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="36"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="2"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="1"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="54.55"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/Batting_two_row"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.30" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/wight"
android:padding="1dp"
android:paddingLeft="2dp"
android:text="Rohid Sharma"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="80"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="40"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="6"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="1"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="101.40"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/batting_table"
android:layout_centerVertical="true"
android:background="#F44238"
android:paddingLeft="2dp"
android:text="Full Commentary"
android:textColor="@color/wight"
android:textSize="20sp"
android:textStyle="bold" 
android:layout_margin="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="68.0dip"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button2"
android:layout_weight="1"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_margin="10dp" >
<RelativeLayout
android:layout_width="56.0dip"
android:layout_height="56.0dip" >
<TextView
android:id="@+id/image_thumbnail"
android:layout_width="48.0dip"
android:layout_height="48.0dip"
android:layout_centerInParent="true"
android:background="@color/ball6"
android:gravity="center_horizontal|center_vertical"
android:text="6"
android:textColor="@color/wight" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="56.0dip"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/text_title"
android:layout_width="fill_parent"
android:layout_height="69dp"
android:layout_marginLeft="6.0dip"
android:paddingBottom="2dp"
android:scrollbars="vertical"
android:singleLine="false"
android:text="David Warner and Joe Burns started off positively and added 49 runs before the former was caught behind when he gloved one off Wagner. Khawaja and Burns then made sure Australia don&apos;t lose any further wickets and negotiated the last few overs."
android:textColor="@color/txtscore"
android:textSize="13.0sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
How to&Answers:

You are using custom android:layout_width and android:layout_height attributes in the xml, hence this xml code will be differently viewed in different devices with different screen sizes.

I would suggest you to study the following developer docs:

Supporting Different Screen Sizes

Supporting Different Screens

Answer:

Either you can use ScrollView, or use different folders for different layout sizes –

layout-ldpi (Low DPI phones) layout-mdpi (Medium DPI phones) layout-hdpi (High DPI phones) layout-xhdpi (Very High DPI phones) layout-xxhdpi (Very Very High DPI phones) 

If you are using Android Studio, it will automatically tell which DPI is suitable for which screen size.

Answer:

  1. You are using static height and width for all control, first of all remove it and use wrap_content.
  2. When it comes to image, keep multiple copies of image in respected folder like drawable-hdpi, drawable-mdpi, drawable-xdpi, drawable-xxdpi.
  3. If your TextView is having large value in future, try to keep it in single line.
  4. Use LinearLayout for main partition of your view. Use of weightsum would help you in more complex situation.
  5. Try to use dimen.xml for text size.
  6. If you think design is more complex, you can use different layout folders also.

Answer:

Since your using static height and weight in dp,

you should define something like this for multiple screen size :

In values folder:

dimen.xml file:

 <!-- Margins --> <dimen name="margin1">1dp</dimen> <dimen name="margin2">2dp</dimen> <dimen name="margin3">3dp</dimen> <dimen name="margin5">5dp</dimen> <dimen name="margin7">7dp</dimen> <dimen name="margin10">10dp</dimen> <dimen name="margin11">11dp</dimen> <dimen name="margin13">13dp</dimen> <dimen name="margin15">15dp</dimen> <dimen name="margin18">18dp</dimen> <dimen name="margin20">20dp</dimen> <dimen name="margin25">25dp</dimen> <dimen name="margin27">27dp</dimen> <dimen name="margin30">30dp</dimen> <dimen name="margin35">35dp</dimen> <dimen name="margin40">40dp</dimen> <dimen name="margin45">45dp</dimen> <dimen name="margin50">50dp</dimen> <dimen name="margin55">55dp</dimen> <dimen name="margin60">60dp</dimen> <dimen name="margin65">65dp</dimen> <dimen name="margin70">70dp</dimen> <dimen name="margin75">75dp</dimen> <dimen name="margin80">80dp</dimen> <dimen name="margin85">85dp</dimen> <dimen name="margin90">90dp</dimen> <dimen name="margin95">95dp</dimen> <dimen name="margin100">100dp</dimen> <!-- Text Size --> <dimen name="text8">8sp</dimen> <dimen name="text10">10sp</dimen> <dimen name="text11">11sp</dimen> <dimen name="text12">12sp</dimen> <dimen name="text13">13sp</dimen> <dimen name="text14">14sp</dimen> <dimen name="text15">15sp</dimen> <dimen name="text16">16sp</dimen> <dimen name="text17">17sp</dimen> <dimen name="text18">18sp</dimen> <dimen name="text19">19sp</dimen> <dimen name="text20">20sp</dimen> <dimen name="text21">21sp</dimen> <dimen name="text22">22sp</dimen> <dimen name="text23">23sp</dimen> <dimen name="text24">24sp</dimen> <dimen name="text25">25sp</dimen> <dimen name="text26">26sp</dimen> <dimen name="text28">28sp</dimen> <dimen name="text30">30sp</dimen> <dimen name="text32">32sp</dimen> <dimen name="text34">34sp</dimen> <dimen name="text35">35sp</dimen> <dimen name="text36">36sp</dimen> <dimen name="text38">38sp</dimen> <dimen name="text40">40sp</dimen> <dimen name="text50">50sp</dimen> <dimen name="text60">60sp</dimen> <dimen name="text65">65sp</dimen> <dimen name="text70">70sp</dimen> <!-- height --> <dimen name="height110">110dp</dimen> <dimen name="height120">120dp</dimen> <dimen name="height130">130dp</dimen> <dimen name="height140">140dp</dimen> <dimen name="height150">150dp</dimen> <dimen name="height160">160dp</dimen> <dimen name="height165">165dp</dimen> <dimen name="height170">170dp</dimen> <dimen name="height175">175dp</dimen> <dimen name="height180">180dp</dimen> <dimen name="height185">185dp</dimen> <dimen name="height190">190dp</dimen> <dimen name="height195">195dp</dimen> <dimen name="height200">200dp</dimen> <dimen name="height220">220dp</dimen> <dimen name="height250">250dp</dimen> <dimen name="height300">300dp</dimen> <dimen name="height330">330dp</dimen> <dimen name="height350">350dp</dimen> <dimen name="height400">400dp</dimen> <!-- Size --> <dimen name="size30">30dp</dimen> <dimen name="size35">35dp</dimen> <dimen name="size50">50dp</dimen> <dimen name="size75">75dp</dimen> <dimen name="size80">80dp</dimen> <dimen name="size100">100dp</dimen> <dimen name="size120">120dp</dimen> <dimen name="size130">130dp</dimen> <dimen name="size150">150dp</dimen> <!-- Padding --> <dimen name="padding1">1dp</dimen> <dimen name="padding2">2dp</dimen> <dimen name="padding3">3dp</dimen> <dimen name="padding4">4dp</dimen> <dimen name="padding5">5dp</dimen> <dimen name="padding6">6dp</dimen> <dimen name="padding7">7dp</dimen> <dimen name="padding8">8dp</dimen> <dimen name="padding9">9dp</dimen> <dimen name="padding10">10dp</dimen> </resources> 

In values-sw600dp folder

dimens file:

<?xml version="1.0" encoding="utf-8"?> <resources> <!-- Margins --> <dimen name="margin1">1dp</dimen> <dimen name="margin2">3dp</dimen> <dimen name="margin3">5dp</dimen> <dimen name="margin5">7dp</dimen> <dimen name="margin7">10dp</dimen> <dimen name="margin10">15dp</dimen> <dimen name="margin11">16dp</dimen> <dimen name="margin13">19dp</dimen> <dimen name="margin15">22dp</dimen> <dimen name="margin18">27dp</dimen> <dimen name="margin20">30dp</dimen> <dimen name="margin25">32dp</dimen> <dimen name="margin27">40dp</dimen> <dimen name="margin30">45dp</dimen> <dimen name="margin35">47dp</dimen> <dimen name="margin40">60dp</dimen> <dimen name="margin45">62dp</dimen> <dimen name="margin50">75dp</dimen> <dimen name="margin55">85dp</dimen> <dimen name="margin60">90dp</dimen> <dimen name="margin65">97dp</dimen> <dimen name="margin70">105dp</dimen> <dimen name="margin75">110dp</dimen> <dimen name="margin80">120dp</dimen> <dimen name="margin85">127dp</dimen> <dimen name="margin90">135dp</dimen> <dimen name="margin95">142dp</dimen> <dimen name="margin100">150dp</dimen> <!-- Text Size --> <dimen name="text8">12sp</dimen> <dimen name="text9">13sp</dimen> <dimen name="text10">15sp</dimen> <dimen name="text11">16sp</dimen> <dimen name="text12">18sp</dimen> <dimen name="text13">19sp</dimen> <dimen name="text14">21sp</dimen> <dimen name="text15">22sp</dimen> <dimen name="text16">24sp</dimen> <dimen name="text17">25sp</dimen> <dimen name="text18">27sp</dimen> <dimen name="text19">28sp</dimen> <dimen name="text20">30sp</dimen> <dimen name="text21">31sp</dimen> <dimen name="text22">33sp</dimen> <dimen name="text23">34sp</dimen> <dimen name="text24">36sp</dimen> <dimen name="text25">37sp</dimen> <dimen name="text26">39sp</dimen> <dimen name="text28">42sp</dimen> <dimen name="text30">45sp</dimen> <dimen name="text32">48sp</dimen> <dimen name="text34">51sp</dimen> <dimen name="text35">52sp</dimen> <dimen name="text36">54sp</dimen> <dimen name="text38">57sp</dimen> <dimen name="text40">60sp</dimen> <dimen name="text50">75sp</dimen> <dimen name="text60">90sp</dimen> <dimen name="text65">97sp</dimen> <dimen name="text70">105sp</dimen> <!-- height --> <dimen name="height110">165dp</dimen> <dimen name="height120">180dp</dimen> <dimen name="height130">195dp</dimen> <dimen name="height140">210dp</dimen> <dimen name="height150">225dp</dimen> <dimen name="height160">240dp</dimen> <dimen name="height165">245dp</dimen> <dimen name="height170">250dp</dimen> <dimen name="height175">260dp</dimen> <dimen name="height180">270dp</dimen> <dimen name="height185">275dp</dimen> <dimen name="height190">285dp</dimen> <dimen name="height195">293dp</dimen> <dimen name="height200">300dp</dimen> <dimen name="height220">330dp</dimen> <dimen name="height250">375dp</dimen> <dimen name="height300">495dp</dimen> <dimen name="height330">440dp</dimen> <dimen name="height350">525dp</dimen> <dimen name="height400">600dp</dimen> <!-- Padding --> <dimen name="padding1">2dp</dimen> <dimen name="padding2">3dp</dimen> <dimen name="padding3">5dp</dimen> <dimen name="padding4">6dp</dimen> <dimen name="padding5">7dp</dimen> <dimen name="padding6">9dp</dimen> <dimen name="padding7">10dp</dimen> <dimen name="padding8">12dp</dimen> <dimen name="padding9">13dp</dimen> <dimen name="padding10">15dp</dimen> </resources> 

In values-sw-720dp

dimens.xml file

<?xml version="1.0" encoding="utf-8"?> <resources> <!-- Margins --> <dimen name="margin1">2dp</dimen> <dimen name="margin2">4dp</dimen> <dimen name="margin3">4dp</dimen> <dimen name="margin5">10dp</dimen> <dimen name="margin7">14dp</dimen> <dimen name="margin10">20dp</dimen> <dimen name="margin11">22dp</dimen> <dimen name="margin13">26dp</dimen> <dimen name="margin15">30dp</dimen> <dimen name="margin18">36dp</dimen> <dimen name="margin20">40dp</dimen> <dimen name="margin25">50dp</dimen> <dimen name="margin27">54dp</dimen> <dimen name="margin30">60dp</dimen> <dimen name="margin35">70dp</dimen> <dimen name="margin40">80dp</dimen> <dimen name="margin45">90dp</dimen> <dimen name="margin50">100dp</dimen> <dimen name="margin55">110dp</dimen> <dimen name="margin60">120dp</dimen> <dimen name="margin65">130dp</dimen> <dimen name="margin70">140dp</dimen> <dimen name="margin75">150dp</dimen> <dimen name="margin80">160dp</dimen> <dimen name="margin85">170dp</dimen> <dimen name="margin90">180dp</dimen> <dimen name="margin95">190dp</dimen> <dimen name="margin100">200dp</dimen> <!-- Text Size --> <dimen name="text8">16sp</dimen> <dimen name="text10">20sp</dimen> <dimen name="text11">22sp</dimen> <dimen name="text12">24sp</dimen> <dimen name="text13">26sp</dimen> <dimen name="text14">28sp</dimen> <dimen name="text15">30sp</dimen> <dimen name="text16">32sp</dimen> <dimen name="text17">34sp</dimen> <dimen name="text18">36sp</dimen> <dimen name="text19">38sp</dimen> <dimen name="text20">40sp</dimen> <dimen name="text21">42sp</dimen> <dimen name="text22">44sp</dimen> <dimen name="text23">46sp</dimen> <dimen name="text24">48sp</dimen> <dimen name="text25">50sp</dimen> <dimen name="text26">52sp</dimen> <dimen name="text28">56sp</dimen> <dimen name="text30">60sp</dimen> <dimen name="text32">62sp</dimen> <dimen name="text34">68sp</dimen> <dimen name="text35">70sp</dimen> <dimen name="text36">72sp</dimen> <dimen name="text38">76sp</dimen> <dimen name="text40">80sp</dimen> <dimen name="text50">100sp</dimen> <dimen name="text60">120sp</dimen> <dimen name="text65">130sp</dimen> <dimen name="text70">140sp</dimen> <!-- height --> <dimen name="height110">220dp</dimen> <dimen name="height120">240dp</dimen> <dimen name="height130">260dp</dimen> <dimen name="height140">280dp</dimen> <dimen name="height150">300dp</dimen> <dimen name="height160">320dp</dimen> <dimen name="height165">330dp</dimen> <dimen name="height170">340dp</dimen> <dimen name="height175">350dp</dimen> <dimen name="height180">360dp</dimen> <dimen name="height185">370dp</dimen> <dimen name="height190">380dp</dimen> <dimen name="height195">390dp</dimen> <dimen name="height200">400dp</dimen> <dimen name="height220">440dp</dimen> <dimen name="height250">500dp</dimen> <dimen name="height300">600dp</dimen> <dimen name="height330">660dp</dimen> <dimen name="height350">700dp</dimen> <dimen name="height400">800dp</dimen> <!-- Padding --> <dimen name="padding1">2dp</dimen> <dimen name="padding2">4dp</dimen> <dimen name="padding3">6dp</dimen> <dimen name="padding4">8dp</dimen> <dimen name="padding5">10dp</dimen> <dimen name="padding6">12dp</dimen> <dimen name="padding7">14dp</dimen> <dimen name="padding8">16dp</dimen> <dimen name="padding9">18dp</dimen> <dimen name="padding10">20dp</dimen> </resources> 

after doing this your able to change ur layout xml file like this:

I have just altered one Linear layout file

you should apply for all other layouts in this xml file

See this below sample: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="vertical" android:scrollbarStyle="insideOverlay" > <LinearLayout android:id="@+id/layout_status" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/wight" android:baselineAligned="false" android:orientation="vertical" > <TextView android:id="@+id/tseriesname" android:layout_width="fill_parent" android:layout_height="@dimen/margin20" android:layout_margin="@dimen/margin5" android:gravity="center" android:singleLine="true" android:text="@string/series_name" android:textColor="@color/textgraycolor" android:textSize="@dimen/text10" android:textStyle="bold" /> .......... .............. ................ ................... 

like this way your app should able support multiple screens.

you can use differ layouts for supporting devices.

and should have images in drawable-hdpi, drawable-mdpi, drawable-xdpi, drawable-xxdpi for perfect view of images.

I think this ll be helpful for ur answer. 🙂

Answer:

Try to use google’s design library. Percentage Layout it will fulfill your requirement

Answer:

Well there are a lot of things you can do

  1. use android:layout_weight and android:weightSum
    a good example can be found by google search like layout weight
  2. You could also use the Android Percent Support Library example and some documentation
  3. You can have different resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default") res/layout-small/my_layout.xml // layout for small screen size res/layout-large/my_layout.xml // layout for large screen size res/layout-xlarge/my_layout.xml // layout for extra large screen size res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation res/drawable-mdpi/my_icon.png // bitmap for medium density res/drawable-hdpi/my_icon.png // bitmap for high density res/drawable-xhdpi/my_icon.png // bitmap for extra high density 
  1. You could support for Smallest Width layout directories, and have individual layouts there for 5″, 7″, 10″ and so on.

     res/layout/main_activity.xml # For handsets (smaller than 480dp available width) res/layout-sw480dp/main_activity.xml # For phones (480dp wide and bigger) res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger) res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger) 
  2. You can also have different value folders to have different dimens.xml for each screen resolution group
    Supporting Multiple Screens

Answer:

Try taking the Parent Layout as Linear Layout and then setting android:weightsum property to parent. Finally, align the child view using weight as android:weightproperty. In this way, you can have uniform UI across all the screen sizes.

Answer:

You should use layout_weight and change the
android:layout_width="(fixedvalue)"
and android:layout_height="fixed_value" to android:layout_width="match_parent” and android:layout_height="wrap_content". You can do some research and you will find this easy to understand.

Answer:

You can create you layout through code rather than layout.xml.