0

I tried to create a GUI - GridLayout 2 rows & 2 cols (you can see in the image). I want the button width is fit the column (2) width. But the result is overflow.

enter image description here

Do you have ever get this kind of issue?

Here are my code

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginTop="15dp"
    android:background="@drawable/round_corner_opacity_background"
    android:columnCount="2"
    android:rowCount="6">
    <!--Pick up-->
    <ImageView
        android:layout_column="0"
        android:layout_gravity="center_vertical"
        android:layout_margin="5dp"
        android:layout_row="0"
        android:layout_rowSpan="2"
        android:src="@drawable/ic_ci_pick_up" />

    <TextView
        style="@style/text_view_description"
        android:layout_column="1"
        android:layout_columnWeight="1"
        android:layout_row="0"
        android:text="@string/pick_up" />

    <Button
        android:id="@+id/btnSelectPickUp"
        style="@style/button_location"
        android:layout_column="1"
        android:layout_columnWeight="1"
        android:layout_row="1"
        android:maxLines="3"
        android:singleLine="false"
        android:text="@string/select_pick_up" />
    <!--Separator-->
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_column="1"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:layout_row="2"
        android:background="@color/primary" />
    <!--Drop off-->
    <ImageView
        android:layout_column="0"
        android:layout_gravity="center_vertical"
        android:layout_margin="5dp"
        android:layout_row="3"
        android:layout_rowSpan="2"
        android:src="@drawable/ic_ci_drop_off" />

    <TextView
        style="@style/text_view_description"
        android:layout_column="1"
        android:layout_columnWeight="1"
        android:layout_row="3"
        android:text="@string/drop_off" />

    <Button
        android:id="@+id/btnSelectDropOff"
        style="@style/button_location"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_columnWeight="1"
        android:layout_row="4"
        android:ellipsize="end"
        android:singleLine="true"
        android:text="@string/select_pick_up" />
    <!--ConfirmedBookings-->
    <Button
        android:id="@+id/btnShowConfirmedBookingsDialog"
        style="@style/button_default"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_column="0"
        android:layout_columnSpan="2"
        android:layout_marginTop="15dp"
        android:layout_row="5"
        android:text="@string/confirmed_booking" />
</GridLayout>

<Button
    android:id="@+id/btnShowBookDialog"
    style="@style/button_default"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center|bottom"
    android:text="@string/book" />

Thank you,

SamuelD
  • 333
  • 2
  • 10
Bac Clunky
  • 353
  • 3
  • 6
  • 18

1 Answers1

0

Can you post a piece of code? Can you sret you width to fill parent for that button instead of android:layout_columnWeight="1"

I would work with weights. With that you can specify your width in the parent that you have set match parent.

Reference: Android Weights

Also check: Shrink and Stretch columns

Community
  • 1
  • 1
SamuelD
  • 333
  • 2
  • 10