1

そのため、シリアル経由で arduino と通信するための Android アプリを作成しています。順調に進んでいますが、レイアウトに問題があります。TextView上も下も重なっているのですが、原因がわかりません!

https://www.dropbox.com/s/jaz8vbx63kd25ix/Screenshot_2012-09-27-18-53-24.png

ここに私のmain.xmlがあります:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="20dp" >

    <TextView
        android:id="@+id/demoTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <ScrollView
        android:id="@+id/demoScroller"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/demoText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:typeface="monospace" />

    </ScrollView>

    <RelativeLayout
        android:id="@+id/send"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@+id/sendButton"

        android:ems="10"
        android:hint="@string/send_text"
        android:inputType="text"
        android:singleLine="true" >
     </EditText>

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

    </RelativeLayout>

</FrameLayout>

前もって感謝します。

4

1 に答える 1

1

これはFrameLayout、「単一の子ビューを保持するために使用する必要があります。子が互いに重ならないように異なる画面サイズに拡張できるように子ビューを整理するのは難しい場合があるためです」. LinearLayout縦向きでを使用してみてください。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="20dp"
    android:orientation="vertical" >

    <TextView
    android:id="@+id/demoTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

    <!-- ... -->

    </RelativeLayout>

</LinearLayout>
于 2012-09-27T23:19:45.573 に答える