1

リストビューの行要素を揃えようとしています。このコードを保持するレイアウト行のxmlファイルがあります。

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

    <TextView
        android:id="@+id/TV_list_from_db_p_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp" >

        <Button
            android:id="@+id/BTN_addOne_from_db"
            android:layout_width="33dp"
            android:layout_height="wrap_content"
            android:background="@drawable/button"
            android:onClick="addOneToQuantity"
            android:text="+" />

        <EditText
            android:id="@+id/TV_Quantity_from_db"
            android:layout_width="44dp"
            android:layout_height="32dp" >
        </EditText>

        <Button
            android:id="@+id/BTN_subOne_from_db"
            android:layout_width="33dp"
            android:layout_height="wrap_content"
            android:background="@drawable/button"
            android:onClick="subOneToQuantity"
            android:text="-" />
    </LinearLayout>

    <CheckBox
        android:id="@+id/CHK__list_from_db"
        android:layout_width="30dp"
        android:layout_height="30dp"
  />

</LinearLayout>

このコードは私にこれを与えます: 要素を整列させたいのですが、今度はテキストビューの長さで整列します

このように:
| TextView | Number Picker | チェックボックス|
|TextView|ナンバーピッカー| チェックボックス|
|TextView|ナンバーピッカー| チェックボックス|

何か案は?

4

2 に答える 2

2

LinearLayoutを使用しているので、内部のLinearLayoutとCheckBoxの両方layout_width="wrap_content"を指定し、TextViewlayout_width="0dp"layout_weight="1"

于 2013-01-11T15:38:12.793 に答える
0

相対レイアウトを使用して、次の順序で配置します。

Check box - align parent right - width="30dp"
Button1 - to left of check box - width="33dp"
Edit Text - to left of Button1 - width="44dp"
Button2 - to left of Edit Text - width="33dp"
TextView - align parent left and to left of Button2 - width wrap_content
于 2013-01-11T16:09:12.503 に答える