2011-11-23 106 views
1

我有一个PopupWindow填充LinearLayout。我instatiated像这样我的弹出窗口:如何允许在Android的PopupWindow滚动

PopupWindow pw = new PopupWindow(layout, 450, 700, true); 
pw.showAsDropDown(layout, 80, 80); 

然而,当设备方向被切换为横向,在弹出的窗口被在底部切断,我不能向下滚动。查看屏幕截图: enter image description here

此弹出窗口下的布局确实是可滚动的。那么我怎样才能让弹出窗口滚动?

感谢, 伊戈尔

回答

3

LinearLayouts不滚动,所以不是在ScrollView封闭的LinearLayout。

+0

我在弹出下面有一个LinearLayout,而弹出窗口本身是在LinearLayout中。但是,当我尝试将弹出窗口的代码放在ScrollView中时,它只是放大并退出屏幕,但不滚动。奇怪... –

+0

除此之外,我不能有2个像这样的ScrollViews。我收到一个错误:“java.lang.IllegalStateException:查看[email protected]已被添加到窗口管理器” –

+0

您需要使用新的ScrollView,而不是重新使用现有的。 – kabuko

4

我这样做是使用这个和工作:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout_popup" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
<ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#444444"> 

</RelativeLayout> 
</ScrollView> 
</LinearLayout> 

我希望能对您有用。再见

+1

你的LinearLayout是无用的;通过用ScrollView替换根可以提高性能。 –