当屏幕旋转时,活动界面无法滚动

5
当我旋转手机屏幕时,我无法看到整个屏幕。这没关系,但我无法滚动!我需要设置一些标志或属性来滚动吗?这是我的XML的一部分...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_width="fill_parent" android:layout_height="fill_parent" >
    <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="*">
        ...
    </TableLayout>
    <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" 
        ...
    </TableLayout>
</LinearLayout>

谢谢!

2个回答

6

为了使页面可以滚动,您需要将完整的布局放入一个 ScrollView 中。

当您的布局高度大于屏幕高度时,通常在横向模式下会发生滚动。

在您的情况下,将 LinearLayout 放入 ScrollView 中,因为 ScrollView 只能有一个子元素。


尝试过了但现在应用程序崩溃了: 进程myapp意外停止。有什么想法吗? - Reto
请发布您的崩溃日志,我想不出为什么会崩溃。 - Yashwanth Kumar
抱歉,我是新手,请问如何获取日志? - Reto
嗯,通常你可以在logCat窗口中看到这个信息,请查看其中的消息。 - Yashwanth Kumar
ScrollView没有任何参数不太高兴:<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     android:scrollbars="none"     android:layout_width="fill_parent" android:layout_height="fill_parent" > 现在它工作了!谢谢! - Reto

1
你必须知道,为了使用一个scrollView你必须只放置一个组件(可能是一个linearLayout)。如果你试图在该级别放置更多的组件,那可能就是你的问题所在。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接