GridLayout child View pops out of the screen

Asked 2 years ago, Updated 2 years ago, 31 views

I use GridLayout to make a table with 2 horizontal and 4 vertical squares.TextView with address on the right side of the TextView with address written on it, but this TextView sticks out to the right side of the screen.Is it possible to adjust this well to the GridLayout display area?

GridLayout screenshot

The layout XML looks like this.

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:columnCount="2"
    android:useDefaultMargins="true">

    <TextView
        android:text="Phone number"
        android: textColor="@color/colorPrimary"/>

    <TextView
        android: id="@+id/tel"/>

    <TextView
        android:text="Address"
        android: textColor="@color/colorPrimary"/>

    <TextView
        android:id="@+id/address"
        android:text="Roppongi XXXX-YYYY-ZZZ-123456 789000 123456 789"/>

    <!--- hereinafter abbreviated -->
</GridLayout>

android

2022-09-29 21:31

1 Answers

<GridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:columnCount="2"
    android:useDefaultMargins="true">

  <TextView
      android:text="Phone number"
      android: textColor="@color/colorPrimary"/>

  <TextView
      android: id="@+id/tel"
      tools:text="0123456"/>

  <TextView
      android:text="Address"
      android: textColor="@color/colorPrimary"/>

  <TextView
      android:id="@+id/address"
      android:layout_width="0dp"
      android:layout_gravity="fill_horizontal"
      tools:text="Roppongi XXXX-YYYY-ZZZ-123456 789000 123456 789"/>

  <!--- hereinafter abbreviated -->
</GridLayout>


2022-09-29 21:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.