0

これはに表示するための私のXMLですuser's informationListViewしたがって、現在、TextViewユーザーの情報を表示している2つのXMLが含まれています。

問題文:-

アプリケーションを実行するときはいつでも、両方がText View並んでいるのが見えます。たとえば、私はいつも以下のようなものを手に入れます-

SomeImage             TextView1             TextView2

それは私が望まないものです。私はこのようなものが必要です-そして私が将来3つのTextViewを持っていると仮定します。

SomeImage             TextView1

                      TextView2

                      TextView3

以下は、現在使用しているXMLファイルです。必要な出力を常に取得できるように、これを変更するにはどうすればよいですか?

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

    <ImageView
        android:id="@+id/image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:scaleType="centerCrop"
        android:src="@drawable/stub" />

    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_marginLeft="10dip"
        android:layout_weight="1"
        android:textSize="10dip" />

    <TextView
        android:id="@+id/text1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_marginLeft="10dip"
        android:layout_weight="1"
        android:textSize="10dip" />

</LinearLayout>
4

2 に答える 2

3

これを試して:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="50dip"
    android:layout_height="50dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="10dp"
    android:src="@drawable/stub" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/imageView1"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView1" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView2" />


<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView3" />

</RelativeLayout>
于 2012-08-19T22:10:44.950 に答える
2

LinearLayoutの方向はデフォルトで水平です。この行をあなたのに追加するだけです<LinearLayout>

android:orientation="vertical"
于 2012-08-19T22:14:15.053 に答える