2

の各行に使用されるレイアウトを設定しようとしていますListActivity。各行には、左側に電球アイコン、中央にテキスト、右側にペンアイコンが含まれています。

中央のテキスト部分が大きくなった場合に2つの画像を渡すのを避けるための解決策を見つけることができません。

これが私が画面に表示したものです:

実際の表示

テキストが長すぎる場合は、電球アイコンペンアイコンの上に表示されます

レイアウトを変更して回避するにはどうすればよいですか?

XML:

<RelativeLayout
    android:id="@+id/linearLayoutEquipementInfo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20sp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/equipementImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_margin="10sp"
        android:contentDescription="@string/status" />

    <TextView
        android:id="@+id/equipementName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_margin="10sp"
        android:gravity="center"
        android:text="title"
        android:textSize="22sp" />

    <ImageView
        android:id="@+id/equipementEdit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_margin="1sp"
        android:background="@null"
        android:contentDescription="@string/editEquipmentName"
        android:src="@android:drawable/ic_menu_edit" />
</RelativeLayout>
4

3 に答える 3

2

TextViewには2つのパラメータを追加できます。

android:layout_toRightOf="@id/equipementImage"
android:layout_toLeftOf="@id/equipementEdit"
于 2012-07-12T09:43:18.743 に答える
0

RelativeLayout次のような属性android:layout_belowを使用します。

このビューの上端を、指定されたアンカービューIDの下に配置します。

したがって、あなたの場合、あなたはあなたので使用する必要がありandroid:layout_below="@id/equipementImage"ますTextView

于 2012-07-12T09:43:08.023 に答える
0

レイアウトxmlで重みの合計を使用できると思います。

このような。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayoutEquipementInfo"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="20sp"
    android:weightSum="1.0"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.1"
        android:orientation="horizontal"
        android:weightSum="1.0" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.15"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.70"
            android:gravity="center"
            android:text="TextView" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.15"
            android:src="@drawable/ic_launcher" />

    </LinearLayout>

</LinearLayout>

これで問題が解決する場合があります。

于 2012-07-12T09:53:05.557 に答える