0

GridLayout について 2 つの質問があります。

  1. 親を埋めるように言ったのに、親が親と一致するように設定されているのに、レイアウトが電話を超えて拡張されるのはなぜですか?
  2. 3 番目のテキストビュー (「日付」と表示されているもの) が壊れているのはなぜですか? 予約と書かれたものと日付と書かれたものの間に大きなスペースがあります。

ありがとう!

ここに画像の説明を入力

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/GridLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:columnCount="2"
    android:rowCount="4"
    tools:context=".GridLayoutActivity" >

    <ImageView
        android:id="@+id/imgCabin1"
        android:layout_column="0"
        android:layout_row="0"
        android:layout_rowSpan="3"
        android:layout_height="248dp"
        android:scaleType="fitCenter"
        android:layout_width="200dp"
        android:src="@drawable/sky_beach" 
        android:background="#222222"/>

    <TextView
        android:id="@+id/txtCabint1Title"
        android:layout_width="fill_parent"
        android:layout_height="72sp"
        android:layout_column="1"
        android:layout_row="0"
        android:padding="10sp"
        android:text="Sky Beach"
        android:textSize="48sp" />

    <TextView
        android:id="@+id/txtCabinDesc"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_gravity="left"
        android:layout_row="1"
        android:maxLines="5"
        android:padding="10sp"
        android:singleLine="false"
        android:text="Dog friendly vacation rental cabin on a scenic mountain river"
        android:textSize="24sp" />

    <TextView
        android:id="@+id/btnCabin1Reserve"
        android:layout_width="fill_parent"
        android:layout_height="60sp"
        android:background="#888888"
        android:gravity="left"
        android:layout_column="1"
        android:layout_row="2"
        android:text="Reserve"
        android:textSize="36sp" 
        android:padding="10sp"  />

    <TextView
        android:id="@+id/txtCabinDesc"
        android:layout_width="fill_parent"
        android:layout_height="60sp"
        android:layout_gravity="top"
        android:layout_column="1"
        android:layout_row="3"
        android:text="Date: "
        android:textSize="36sp" 
        android:padding="10sp"  />


</GridLayout>
4

1 に答える 1

1

グリッドビューを使用する代わりに、なぜ相対レイアウトを使用せず、レイアウトを相対的に設定するのですか?2番目の問題は、グリッド行を次々に設定しているためです。したがって、イメージビューを設定した後、テキストビューtxtCabinDescを設定します。私が試したスニペット。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/GridLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2"
android:rowCount="4" >

<ImageView
    android:id="@+id/imgCabin1"
    android:layout_column="0"
    android:layout_row="0"
    android:layout_rowSpan="3"
    android:layout_height="248dp"
    android:scaleType="fitCenter"
    android:layout_width="200dp"
    android:src="@drawable/ic_launcher" 
    android:background="#222222"/>

<TextView
    android:id="@+id/txtCabint1Title"
    android:layout_width="match_parent"
    android:layout_toRightOf="@id/imgCabin1"
    android:layout_height="72sp"
    android:layout_column="1"
    android:layout_row="0"
    android:padding="10sp"
    android:text="Sky Beach"
    android:textSize="48sp" />

<TextView
    android:id="@+id/txtCabinDesc"
    android:layout_width="match_parent"
    android:layout_toRightOf="@id/imgCabin1"
    android:layout_below="@id/txtCabint1Title"
    android:layout_height="wrap_content"
    android:layout_column="1"
    android:layout_gravity="left"
    android:layout_row="1"
    android:maxLines="5"
    android:padding="10sp"
    android:singleLine="false"
    android:text="Dog friendly vacation rental cabin on a scenic mountain river"
    android:textSize="24sp" />

<TextView
    android:id="@+id/btnCabin1Reserve"
    android:layout_width="match_parent"
    android:layout_toRightOf="@id/imgCabin1"
    android:layout_below="@id/txtCabinDesc"
    android:layout_height="60sp"
    android:background="#888888"
    android:gravity="left"
    android:layout_column="1"
    android:layout_row="2"
    android:text="Reserve"
    android:textSize="36sp" 
    android:padding="10sp"  />

<TextView
    android:id="@+id/txtCabinDesc1"
    android:layout_width="match_parent"
    android:layout_toRightOf="@id/imgCabin1"
    android:layout_below="@id/btnCabin1Reserve"
    android:layout_height="60sp"
    android:layout_gravity="top"
    android:layout_column="1"
    android:layout_row="3"
    android:text="Date: "
    android:textSize="36sp" 
    android:padding="10sp"  />

また、説明の textView の ID と競合するため、最後の textView の ID を変更します。

于 2014-06-17T18:03:58.590 に答える