3

imageview と scrollview を含む linearlayout A があります。scrollview には 2 番目の linearlayout B が含まれています。linearLayout B には、scrollview の高さと正確に一致する複数のビューが含まれている一方で、固定ヘッダーを使用するという考え方です。スクロールビューですべてのタブが互いに並んでいるタブビューとして見てください。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/main_view"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000"
    android:orientation="vertical">

<ImageView android:id="@+id/logoImg"
    android:layout_width="fill_parent"
    android:gravity="center"
    android:src="@drawable/logo"
    android:layout_height="wrap_content"/>

<ScrollView
  android:id="@+id/scrollView"
  android:layout_weight="1"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"> 

<LinearLayout android:id="@+id/scrollLinear"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
</ScrollView>
</LinearLayout>

scrollView で getHeight を呼び出して、この高さを linearLayout B の各ビューに設定することでこれを達成しようとしましたが、getHeight は常に 0 を返します。これを達成する最も簡単な方法は何ですか?

4

1 に答える 1

3

さて、質問は非常に古いですが、試してみます:) ScrollViewに「fillViewport」がないのではないでしょうか?

  <ScrollView
    android:id="@+id/scrollView"
    android:layout_weight="1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    android:fillViewport="true" 

    >
于 2012-11-25T01:31:42.703 に答える