1

複数のソリューションを試しましたが、どれもうまくいかないようです。レイアウト:

--------------------
|btn1|  txt1  |btn2|
--------------------
|                  |
|                  |
|                  |
|     txtview1     |
|                  |
|                  |
|                  |
--------------------

btn1 - 左上揃え - txt1を減らす btn2
- 右上揃え - txt1
を増やす

4

2 に答える 2

3

これを試して:

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

    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="btn1"/>

    <TextView
        android:id="@+id/txt1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="txt1"/>

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

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/btn1">

        <TextView
            android:id="@+id/txt2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="txt2"/>

    </ScrollView>

</RelativeLayout>
于 2010-04-12T12:28:50.653 に答える
1

また、2 番目のボタンを右に揃える必要があります。
あなたのバージョンは、最初のボタンの上に 2 番目のボタンを配置します...

例:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

    <Button android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="back"/>
    <TextView android:id="@+id/txt1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:text="txt1"/>
    <Button android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="btn2"/>

    <ScrollView android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@id/button1">

        <TextView android:id="@+id/txt2"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:layout_below="@id/button2"
                  android:text="txt2"/>
    </ScrollView>
</RelativeLayout>
于 2011-05-01T01:59:21.337 に答える