0

Having a few issues with getting my linear layout to fill the screen when testing on a tablet. On a phone it works fine but this is what happens on a tablet:

enter image description here

Here is the xml code, I have looked at suggestions for scroll view, etc but nothing has worked so far!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="100">


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="33.3">
        <TextView
            android:id="@+id/tvOrderNumber"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:gravity="center"
            android:text=""
            android:textAlignment="center" />

        <TextView
            android:id="@+id/tvDateTime"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:text=""
            android:gravity="center"/>

    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="33.3">
        <TextView
            android:id="@+id/tvItemType"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:gravity="center"
            android:text=""
            android:textSize="18sp"
            android:textStyle="bold" />
    </LinearLayout>





    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="33.3">

        <TextView
            android:gravity="center"
            android:text="Name"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:id="@+id/tvItemName"
            android:layout_below="@+id/textView2"/>
        <TextView
            android:gravity="center"
            android:text="Qty"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:id="@+id/tvItemQty"
            android:layout_below="@+id/textView2"/>
    </LinearLayout>

</LinearLayout>

And this is how AndroidStudio says it will display on a 10.1" tablet

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
androidUser1993
  • 145
  • 1
  • 9
  • It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly). – Ben P. Aug 15 '18 at 20:31
  • Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it! – androidUser1993 Aug 15 '18 at 20:42
  • For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer. – Ben P. Aug 15 '18 at 21:03
  • I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing! – androidUser1993 Aug 15 '18 at 21:16
  • Possible duplicate of [What does android:layout\_weight mean?](https://stackoverflow.com/questions/3995825/what-does-androidlayout-weight-mean) – Martin Zeitler Jan 01 '19 at 15:57

2 Answers2

0

I cannot reproduce your error on an emulator.

Try make the inner layouts android:layout_width="0dp" and android:layout_weight="1", and remove android:weightSum="100".

Xi Wei
  • 1,669
  • 1
  • 21
  • 33
0

You have to add landscape orientation for your app in resources and redesign layout for horizontal layout. Here is the guide

JAGUAR
  • 21
  • 8