0

请查看以下负责创建 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 新手,这是我的第二个应用程序。请帮忙! 日食内部 Android内部运行

4

3 回答 3

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 所说的 fillViewportDefines whether the scrollview should stretch its content to fill the viewport.

于 2012-07-27T06:07:13.570 回答
1

我认为你应该在 LinearLayout 中使用 wrap_content

于 2012-07-27T06:01:38.250 回答
1

像这样改变这个2

<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" />
于 2012-07-27T06:06:11.897 回答