无法滚动

时间:2012-07-27 05:58:59

标签: java android eclipse android-layout android-emulator

请查看以下负责创建GUI的android xml文件

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent">


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/imageTitle"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="14dp"
        android:text="@string/imageDate"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="254dp"
        android:layout_weight="0.34"
        android:src="@drawable/test_image" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="fill_parent"
        android:layout_height="136dp"
        android:text="@string/imageDescription" />

</LinearLayout>
</ScrollView>

我正在尝试滚动整个屏幕,但它没有发生。上传的图片会让您清楚。为什么不滚动?我是Android新手,这是我的第二个应用程序。请帮忙! Inside eclipse Inside Android run

3 个答案:

答案 0 :(得分:2)

使用滚动视图,如果你有整个视图可滚动,请使用滚动视图作为父布局并使用这样的代码。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">

这里android:fillViewport="true"这是重要的部分,它允许你填充整个屏幕的布局。如果有任何其他问题要求。

正如android.developer所说的fillViewport Defines whether the scrollview should stretch its content to fill the viewport.

答案 1 :(得分:1)

我认为你应该在LinearLayout

中使用wrap_content

答案 2 :(得分:1)

像这样改变这个

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


<TextView
     android:id="@+id/textView3"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="@string/imageDescription" />