1

Androidアプリの開発にEclipseを使用しており、互いに接続する3つのボタンを作成したいだけです。これは MyActivity .xml で、このように見えますが、スペースのないボタンが必要なボタンを実行したいと考えています。

    <Button
        android:id="@+id/button1
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="0dp"
        android:layout_marginLeft="0dp"
        android:text="Button" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="0dp"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Button" />

ここに画像があります

有効な XHTML.

4

4 に答える 4

2

そのためのマージンを設定できます。

<Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="-10dp"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Button" />

マイナスマージンを設定し、結果を確認してください。

于 2012-10-18T13:24:58.540 に答える
2

内側にボタンがある LinearLayout を使用します。

<LinearLayout
     <Button/>
     <Button/>
     <Button/>
/>

その後、必要に応じて LinearLayout を配置できます (中央、右、左、...)

于 2012-10-18T13:26:31.377 に答える
0

RelativeLayout を使用してそれを RelativeLayout の中央に配置し、 3つのボタン (
button1 、button2、button3) を作成し、次の属性を 与え
ます 。-button3: totheRightOf = button2 , alignparentRight = true .



それが役立つことを願っています

于 2012-10-18T13:28:16.983 に答える
0

android:layout_weight="1"すべてのボタンでこのように使用するだけです

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button1" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button3" />
</LinearLayout>
于 2012-10-18T13:36:26.967 に答える