Android ScrollView不会自动滚动

时间:2013-12-04 10:36:24

标签: android xml scrollview

我可能在这里遗漏了一些非常简单的东西,但我不能为我的生活看到它。

我正在尝试让ScrollView在Android应用程序中运行。虽然布局看起来不错,但文本/图像不会自动滚动

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
>
<ScrollView 
    android:focusable="true"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:background="#f7f7f7"
    android:layout_weight="1"
    android:fillViewport="true" 
    android:orientation="vertical"
    android:padding="25dp" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        tools:context=".NasaDailyImage" >
        <TextView
            android:id="@+id/imageTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/test_image_title" />
        <TextView
            android:id="@+id/imageDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/test_image_date" />
        <ImageView
            android:id="@+id/imageDisplay"
            android:contentDescription="@string/test_image_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:src="@drawable/test_image" />
        <TextView
            android:id="@+id/imageDescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/test_image_description" />
    </LinearLayout>
</ScrollView>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center" 
        android:layout_weight="0">
        <Button android:text="@string/refresh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:padding="5dp"
            android:background="#ff8D8D8D"
            android:onClick="refreshScreen"
            android:gravity="center"/>
    </LinearLayout>
</LinearLayout>

有没有人有任何想法?

2 个答案:

答案 0 :(得分:0)

为像100dp这样的滚动视图提供一些高度。添加一些文本视图。它会起作用

答案 1 :(得分:0)

<ScrollView 
    android:focusable="true"
    android:layout_width="fill_parent"
    **android:layout_height="fill_parent"**
    android:background="#f7f7f7"
    android:layout_weight="1"
    android:fillViewport="true" 
    android:orientation="vertical"
    android:padding="25dp" />

只需将fill_parent添加到它的滚动视图高度