Android - 页面不滚动

标签 android

我有一个具有这种布局的页面:

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

<TextView
    android:id="@+id/question_label"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Your question: "
    />     

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

<TextView
    android:id="@+id/please_wait"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Please wait while the discussion loads..."
    />     

    <ListView
    android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@+id/label"
        android:textSize="20px" >        
    </ListView>

        <EditText  
            android:id="@+id/question_text"  
            android:layout_height="wrap_content"  
            android:hint="@string/question_comment_hint"  
            android:inputType="textMultiLine"  
            android:lines="5"  
            android:layout_width="fill_parent">  
        </EditText>

<Button  
            android:id="@+id/submit"  
            android:layout_height="wrap_content"  
            android:text="@string/submit"  
            android:onClick="sendFeedback"  
            android:layout_width="fill_parent">  
        </Button>               


</LinearLayout>

出于某种原因,一旦屏幕被填满,它就不会向下滚动。知道为什么会发生这种情况吗?

谢谢!

最佳答案

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

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/question_label"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Your question: " />

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

        <TextView
            android:id="@+id/please_wait"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Please wait while the discussion loads..." />

        <ListView
            android:id="@android:id/list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@+id/label"
            android:textSize="20px" >
        </ListView>

        <EditText
            android:id="@+id/question_text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="some text"
            android:inputType="textMultiLine"
            android:lines="5" >
        </EditText>

        <Button
            android:id="@+id/submit"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:onClick="sendFeedback"
            android:text="some tesxt" >
        </Button>
    </LinearLayout>
</ScrollView>

</LinearLayout>

你必须使用 Scrollview滚动你的 View ,试试上面的代码,希望它能工作。

关于Android - 页面不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10117385/

相关文章:

java - 如何制作像 uber 这样的标记标签?

java - android testBuildType 不工作

java - 从 onLocationMethod 获取 ConcurrentModificationException

android - SQLite 在 where 子句和分组依据中使用带有日期函数的年份

android - 为什么通知 URI 对 MergeCursor 不起作用?

android - 我想在我的 Android 应用程序中添加一个添加到收藏夹选项

android - aSmack,如何强制重新连接?

java - 无法根据第一个微调器值获取第二个微调器值

android - fragment 变得可见

android - 在 Android ADT Eclipse 插件中滚动布局编辑器