Resize table layout according to screen orientation

Asked

Viewed 495 times

0

I’m a little lost in mounting my screens on Android, I’m not able to make the elements fit the screen dimensions. I put fill_parent in the tablerows and in the elements within it, but the editTexts they don’t size up and feel like they’re in wrap_content, and when I turn the screen to horizontal the layout occupies only a part of the screen.

On the vertical screen I put values on width and it was cool but not automatic.

How to make my layout occupy the entire screen automatically?

The canvas in vertical:

a tela na vertical

The canvas in the horizontal:

a tela na horizontal

The code of the layout:

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TextView 
        android:background="@drawable/borda"
        android:padding="5dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Atendimento:"/>

    <EditText
        android:background="@drawable/borda"
        android:padding="5dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/edtAtendimento"
        android:layout_width="155dp"
        android:layout_height="wrap_content"/>

    <TextView 
        android:background="@drawable/borda"
        android:padding="5dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Data/hora:"/>

    <EditText
        android:background="@drawable/borda"
        android:padding="5dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/edtDataHora"
        android:layout_width="160dp"
        android:layout_height="wrap_content"/>

</TableRow>
  • 1

    First suggestion: exchange fill_parent for match_parent. fill_parent this deprecated. If it doesn’t work, I have another suggestion, but it involves a drastic layout modification.

1 answer

1


I think to do this, you will need a much more complex configuration, try putting this in your Edittext android:layout_weight="1".

  • worked out this configuration in the layout with android:layout_weight he sized the width of the screen thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.