"stretch" row in tablelayout

0

Well, I'm programming android, and building layouts for my app. My problem: I can not make the layout of my app fit vertically to different devices.

My xml code:

'' '

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="match_parent"
    android:layout_height="50dp" >

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton4"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton5"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />
</TableRow>

<TableRow
    android:id="@+id/tableRow3"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ToggleButton
        android:id="@+id/toggleButton6"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton7"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton8"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton9"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton10"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />
</TableRow>

<TableRow
    android:id="@+id/tableRow4"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ToggleButton
        android:id="@+id/toggleButton11"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton12"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton13"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton14"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />

    <ToggleButton
        android:id="@+id/toggleButton15"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="ToggleButton" />
</TableRow>

<TableRow
    android:id="@+id/tableRow5"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" />

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Button" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="TextView" />

    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button" />
</TableRow>

'' '

I want my buttons to increase in size on their own when the screen increases, horizontally this already happens due to the stretchColumns tablelayout but how do I do that in vertical tbm?

Thank you!

    
asked by anonymous 20.10.2014 / 13:26

1 answer

2

Well, see that you're using TableRow.

The parent of TableRow should be TableLayout, by Google's GuiLines.

Your TableLayout, with several TableRows in it, should be either filled or match parent in both height and width.

If you want to set a fixed value for height, as I saw in your example of 50dp, you can set a dimension.

Create a Dimen file in the values folder with:

50dp

This will be the default attribute.

For other resolutions, dimensions, densities, etc ...

You can create another values folder, such as values-small

And put that same dimension with lesser value, for example.

    
20.10.2014 / 20:12