1

簡単なフォームを作成しようとしていますが、メッセージを表示するメモ/ヘッダー/タイトルを上部に追加したいと思います。私はそれをやろうとしましたが、テキストが画面から消え、その下のものも押し出されました。これに対抗するにはどうすればよいですか?

これが私のlayout.xmlもので、これがペーストビンにあります:http: //pastebin.com/fNBfQiz8

<TableLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:shrinkColumns="1"
   android:stretchColumns="1" >

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp"
       android:layout_width="match_parent" >
        <TextView
           android:layout_width="match_parent"
           android:text="You can only add a spot based on your current location" />

    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Name:" />
        <EditText android:id="@+id/name" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Address:" />
        <EditText android:id="@+id/addr" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Type:" />
        <Spinner
           android:id="@+id/spinnerType"
           style="@style/AppBaseTheme"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:entries="@array/types_array"
           android:prompt="@string/types_prompt" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Terrain:" />
        <Spinner
           android:id="@+id/spinnerTerrain"
           style="@style/AppBaseTheme"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:entries="@array/ratings_array"
           android:prompt="@string/ratings_prompt" />
    </TableRow>

    <TableRow>
        <TextView android:text="Difficulty:" />
        <Spinner
           android:id="@+id/spinnerDifficulty"
           style="@style/AppBaseTheme"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:entries="@array/ratings_array"
           android:prompt="@string/ratings_prompt" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Description:" />
        <EditText
           android:id="@+id/desc"
           android:gravity="top"
           android:inputType="textMultiLine"
           android:lines="2"
           android:maxLines="2"
           android:scrollHorizontally="false" />
    </TableRow>

    <Button
       android:id="@+id/save"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="Save"
                    android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" />
</TableLayout>

4

1 に答える 1

0

写真を見ずにあなたがどんな問題を抱えているのか完全にはわかりませんが、私はあなたのペーストビンを調べました。一般的なコメントとして、レイアウトのルートビュー(この場合はScrollView)は、おそらくその幅と高さの両方を持っている必要があります。そうしないと、レイアウトが画面を覆っていない空白の領域が表示される、match_parentまたはfill_parent奇妙なスクロール動作が発生します。

これは、TableLayoutsの列の間隔で気の利いたことを行い、ビューが途切れたり、適切なスペースに収まらない理由を理解するのに役立つ可能性のある優れたチュートリアルです。 必要なレイアウトを実現するために、TableRowsとその子で使用する属性に特に注意してください。

ヘッダー情報を表示したいという質問については、2つの選択肢が考えられます。

  1. TableLayoutのスクロール中に画面の上部に固定して表示する場合は、レイアウトのルートビューとして機能するLinearLayoutを作成し、その方向を垂直に設定します。このLinearLayoutの最初の子としてヘッダーを追加し、2番目の子としてScrollViewを追加します。
  2. ヘッダー情報をテーブルと一緒にスクロールする場合は、ScrollViewをルートとして保持し、LinearLayout(これも垂直方向)を作成して、その直接の子にします。ヘッダー情報をLinearLayoutの最初の子として追加し、TableLayoutを2番目の子として追加します。

お役に立てれば。現在表示されているもののスクリーンショットと、目的のレイアウトのモックアップを投稿すると、発生している問題を特定し、コミュニティでサポートを提供するのに役立ちます。

于 2013-03-06T22:39:06.120 に答える