How to allow scrolling in Android's PopupWindow

為{幸葍}努か 提交于 2019-12-11 04:58:49

问题


I have a PopupWindow that is populated with a LinearLayout. I instatiated my popup window like this:

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

However, when the device orientation is switched to landscape, the popup window gets cut off at the bottom and I cannot scroll down. See the screen capture:

The layout underneath this popup is indeed scrollable. So how can I make the popup scrollable?

Thanks, Igor


回答1:


LinearLayouts aren't scrollable, so instead enclose the LinearLayout in a ScrollView.




回答2:


I do it using this and worked:

<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>

I hope it can be useful for you. Bye



来源:https://stackoverflow.com/questions/8249442/how-to-allow-scrolling-in-androids-popupwindow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!