0
votes

I use Androids LinearLayout for each device's different resolution. This way I solve vertical layout problem different resolution.

But I can't solve horizontal layout problem. Ihis is my layout. I want build layout like this.

enter image description here

In this case I use margin left / right but this is not work on different resolution. How to place TextView relate on resolution?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >

<TextView
    android:id="@+id/titleView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="9"
    android:gravity="center"
    android:text="TextView"
    android:textColor="#5a5856"
    android:textSize="35sp" />

<TextView
    android:id="@+id/wordDafinitionView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="3"
    android:textSize="17sp"
    android:layout_marginLeft="25dp"
    android:layout_marginRight="30dp"
    android:text="TextView"
    android:textColor="#5a5856" />


<TextView
    android:id="@+id/TextView01"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="9"
    android:gravity="center"
    android:text="TextView"
    android:textColor="#5a5856"
    android:textSize="35sp" />

</LinearLayout>
1
your screenshot says Referral DeniedYe Lin Aung

1 Answers

0
votes

One solution is you can read the screen sizes with

DisplayMetrics metrics = getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;

and check different device screen sizes,

if((metrics.heightPixels/metrics.density) >= 700)
                {
                    Log.e(" 10 inch Tab", " 10 inch Tab");
                }
            else if((metrics.heightPixels/metrics.density) >= 550)
                {
                    Log.e(" 7 inch Tab", " 7 inch Tab");
                }
            else if((metrics.heightPixels/metrics.density) >= 400)
                {
                    Log.e(" 5 inch Tab / Mobile", " 5 inch Tab / Mobile");
                }
            else
                {
                    Log.e("All other mobile devices", "All mobile other devices");
                }

and then set the width of your TextView accordingly.