1

ただし、次の画面レイアウトを作成しようとしています。

  1. いくつかの TextView を含む行
  2. ユーザー アクションがビューを追加または削除するスクロール ビュー
  3. ボタンライン。

1.や3.は問題ないのですが、2.は困ります。私のスキームは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/mainX"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  android:orientation="vertical">
  <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/labels" 
    android:layout_weight="1">
  <!--Some text view of various sizes -->
  </LinearLayout>
  <ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/dataScroll">
    <LinearLayout 
      android:id="@+id/dataShow" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content">
    </LinearLayout>
  </ScrollView>
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/buttons" 
    android:layout_weight="1">
  <!--some buttons-->
  </LinearLayout>
</LinearLayout>

プログラムを実行すると、ボタンの行が画面の中央にあり、画面に要素を追加すると(dataShowレイアウトでaddViewを使用)、最初の要素は問題なく追加されますが、その後はわかりません何が起こっている。

ありがとう

4

2 に答える 2

0

あなたが何をしようとしているのか正確にはわかりません。

dataShow レイアウトに項目を動的に追加したいようです。LinearLayout を含む ScrollView を使用する代わりに、 dataShow レイアウトにListView (垂直スクロール) またはGallery (水平スクロール) を使用する必要があります。これにより、スクロール機能が提供され、アイテムをリスト/ギャラリーに動的に追加できるようになります。

于 2011-06-11T20:18:42.630 に答える