私はAndroidを初めて使用しますが、メモ帳のチュートリアルを実行しました。今、私は自分のレイアウトを書こうとしています。最終的なレイアウトは、1ページで次のようになります。
1行目:[------検索バー-----][ボタン]
2行目:[text-tab] [text-tab] [text-tab] <-これらのいずれかをクリックして、3行目のコンテンツを変更します
3行目:[残りの高さを埋めるコンテンツ]
...そして、ユーザーがページを左または右にスクロールすると、別のレイアウト/ページが表示されます。
そこで、新しいandroidXMLレイアウトファイルにEclipseのグラフィカルエディターを使用することから始めました。テキストボックスをキャンバスにドラッグしてから、上の図のように幅を広げました。次に、ボタンを最後に追加して、最初の行を完成させました。
以下に何かを追加しようとすると、機能しません。そこで、XMLビューに切り替えました。LinearLayoutをコピーして貼り付け、編集して2行目を作成できるようにしました。
ここでエラーが発生します:HorizontalScrollViewは1つの直接の子のみをホストできます
さて、水平スクロールビューには1つのLinearLayoutのみを含める必要があることを理解しましたが、このレイアウトを設定するための正しい構造は何ですか?
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText1"
android:layout_width="1130dp"
android:layout_height="72dp">
<requestFocus/>
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="152dp"
android:layout_height="72dp"
android:text="Button"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText1"
android:layout_width="1130dp"
android:layout_height="72dp">
<requestFocus/>
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="152dp"
android:layout_height="72dp"
android:text="Button"/>
</LinearLayout>
</HorizontalScrollView>