0

5 つのテキストビューをイメージビューに揃えようとしています。2 列 5 行の gridlayout を作成しました。列 0 には、5 つの行に分割された 5 つのテキストビューがあります。列 1 は、5 行にわたるイメージビューです。しかし、希望のレイアウトが得られません。以下の目的のレイアウトを参照してください。

ここに画像の説明を入力

私のコード:

<GridLayout
        android:id="@+id/gridlayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:columnCount="2"
        android:layout_below="@+id/titel_over_ons">

        <TextView
            android:id="@+id/intro"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:layout_row="0"
            android:layout_column="0"
            android:text="" />

        <ImageView
            android:id="@+id/foto_over_ons"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_column="1"
            android:layout_row="0"
            android:layout_gravity="end"
            android:contentDescription="@string/dm_design_webdesign_moobiele_applicaties_en_grafische_vormgeving" />

        <TextView
            android:id="@+id/titel_dr"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:layout_row="1"
            android:layout_column="0"
            android:layout_gravity="start"
            android:text="" />

        <TextView
            android:id="@+id/tekst_dr"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:layout_row="2"
            android:layout_column="0"
            android:layout_marginTop="10dp" />


        <TextView
            android:id="@+id/titel_service"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:layout_row="3"
            android:layout_column="0"
            android:layout_marginTop="15dp"
            android:text="" />

        <TextView
            android:id="@+id/tekst_service"
            android:layout_width="0dp"
            android:layout_gravity="start"
            android:layout_height="wrap_content"
            android:layout_row="4"
            android:layout_column="0"
            android:layout_marginTop="10dp" />


    </GridLayout>

誰かがこの問題で私を助けることができますか? ありがとうございました。

4

3 に答える 3

1

このコードは、均等に分割された TextView を表示します。

(背景を削除します。これらはビューの提案用です)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:background="#222" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:background="#675" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:background="#989" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:background="#e34" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:background="#e76" />




    </LinearLayout>

    <ImageView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:layout_marginStart="10dp"
        android:background="#eae"
        />



</LinearLayout>]

Imagem de como ficaria

于 2016-07-08T13:56:10.950 に答える
0

次の属性のいずれかを使用して、要素のスパンを設定できます。

android:layout_columnSpan="..."
android:layout_rowSpan="..."

あなたの場合、それは

android:layout_columnSpan="5"
于 2016-07-08T13:18:06.853 に答える
0

このタイプのレイアウトを設計するのに適した xml には、以下のコードを使用します。

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:text="One"
        android:background="@android:color/white"            
        android:layout_weight="1"
        android:gravity="center"/>

    <View
        android:layout_height="5dp"
        android:layout_width="match_parent"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Two"
        android:background="@android:color/white"
        android:layout_weight="1"
        android:gravity="center"/>

    <View
        android:layout_height="5dp"
        android:layout_width="match_parent"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Three"
        android:background="@android:color/white"
        android:layout_weight="1"
        android:gravity="center"/>

    <View
        android:layout_height="5dp"
        android:layout_width="match_parent"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Four"
        android:background="@android:color/white"
        android:layout_weight="1"
        android:gravity="center"/>

    <View
        android:layout_height="5dp"
        android:layout_width="match_parent"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Five"
        android:background="@android:color/white"
        android:layout_weight="1"
        android:gravity="center"/>        

</LinearLayout>

<View
    android:layout_width="5dp"
    android:layout_height="match_parent"/>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:layout_weight="1"
    android:background="@drawable/ic_launcher"/>

</LinearLayout>
于 2016-07-08T13:24:35.807 に答える