0
我試圖創建一個網格佈局,可以在平板電腦上的橫向和縱向上使用。我只有2列,但我遇到了一個問題,設置孩子的寬度。Android - 在GridLayout中設置一個孩子的寬度爲fill_parent導致兒童被剪裁
將GridLayout
設置爲match_parent
。然後我嘗試將我的TextView
設置在GridLayout
到match_parent
之間,認爲它會延伸到GridLayout
之內。但我看到TextView
的寬度超過了屏幕的邊緣。 (見截圖)
如果我在列0刪除TextView
,它將正常伸展。
這裏是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView17" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="7"
android:layout_row="0"
android:orientation="horizontal"
android:layout_rowSpan="21"
android:layout_gravity="center_horizontal|left"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/linearLayout4">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="119dp"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical|center_horizontal">
<ImageButton
android:id="@+id/phonebtn"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:background="@drawable/phonebtn_cchange"
android:cropToPadding="true"
android:scaleType="fitXY" />
</LinearLayout>
<GridLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/linearLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView127"
android:layout_row="0"
android:layout_column="0" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView128"
android:layout_row="0"
android:layout_column="1" />
</GridLayout>
</RelativeLayout>
我認爲我設置的權重錯了,還是一處山坳跨度,但我不知道。任何幫助,將不勝感激。
這就是我一直在尋找的東西。謝謝! – taciosd