4

これは私のコードです:

<TableRow
    android:layout_width="fill_parent" 
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" > 

    <TextView
        android:id="@+id/TextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="This Button:"
        android:layout_marginLeft="14dp" />

    <ToggleButton
        android:id="@+id/toggleButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="ToggleButton" />


    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="fill_parent" 
        android:layout_weight="0.9" >
    </FrameLayout> 
</TableRow>     

アプリを起動すると、次のようになります。

  This Button:     Togglebutton

テキスト ビューとトグル ボタンの間には十分なスペースがあります。

4

2 に答える 2

0

ギャップを埋めたいと仮定android:gravity="right"して、TextView を試してください。

それでもうまくいかない場合はandroid:layout_weight、TextView と ToggleButton の両方に異なる値を設定して遊んで、水平方向の間隔のバランスを取ります。

于 2013-07-14T17:54:15.690 に答える