4

2 つの列を含むように UI を設計する必要があります。

最初の列は含まれているラベルを折り返す必要があり、同じ行の 2 番目の列はスペース全体を埋める必要があります。いくつかの例の下に:

http://temp.chrzanowski.info/so_layout.png

これどうやってするの ?

4

4 に答える 4

2

Following TableLayout would give you the desired output:

<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
   <TableRow>
      <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Bla bla bla"
           android:singleLine="true" />            <!-- first column's view -->

      <EditText
           android:layout_width="fill_parent"
           android:layout_height="wrap_content" /> <!-- second column's view -->
   </TableRow>

   ...

</TableLayout>
于 2012-07-18T10:08:52.143 に答える
0

別の方法として、次のようにLinearLayoutを実行できます。

<?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="wrap_content"
    android:orientation="horizontal"
    android:weightSum="100"
    android:gravity="center_vertical">
    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="40">
        <TextView
            android:layout_weight="1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:text="A very very very long text"
            android:singleLine="true"
            android:scrollHorizontally="true"
            android:ellipsize="end">
        </TextView>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="60">
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="TextBox">
        </EditText>
    </LinearLayout>
</LinearLayout>

列の幅を調整するにはlayout_weight、各LinearLayoutコンテナのを変更します。値が小さいほど幅が狭くなり、両方の重みが100に等しくなる必要があります。

于 2012-07-18T10:27:19.610 に答える
-1

これを試して:

<?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="fill_parent"
    android:orientation="horizontal" >



        <LinearLayout 
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">


            <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Label 1"
                android:layout_marginLeft="7dp"
                android:layout_marginTop="20dp"/>
            <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Label Loooong2"
                android:layout_marginLeft="7dp"
                android:layout_marginTop="30dp"/>
            <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Label 3"
                android:layout_marginLeft="7dp"
                android:layout_marginTop="30dp"/>
        </LinearLayout>

        <LinearLayout 
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:orientation="vertical">

            <EditText 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:hint="TextBox"/>
            <EditText 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:hint="TextBox"/>
            <EditText 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:hint="TextBox"/>
        </LinearLayout>


</LinearLayout>
于 2012-07-18T10:21:10.640 に答える