如何在Android的PopupWindow中滚动

时间:2011-11-23 21:40:19

标签: android scroll popupwindow

我有一个填充了LinearLayout的PopupWindow。我这样设置了弹出窗口:

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

但是,当设备方向切换为横向时,弹出窗口会在底部被切断,我无法向下滚动。看屏幕截图: enter image description here

此弹出窗口下的布局确实可以滚动。那么如何让弹出窗口可滚动?

谢谢, 伊戈尔

2 个答案:

答案 0 :(得分: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 :(得分:3)

LinearLayouts不可滚动,因此请将LinearLayout包含在ScrollView中。