【发布时间】:2016-03-09 02:09:10
【问题描述】:
我尝试创建一个 GUI - GridLayout 2 行和 2 列(您可以在图像中看到)。我希望按钮宽度适合列 (2) 宽度。但是结果溢出了。
你遇到过这种问题吗?
这是我的代码
<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" />
谢谢,
【问题讨论】:
标签: android android-gridlayout column-width