繁体   English   中英

如何在Android的弹出窗口中实现垂直滚动?

[英]how to implement vertical scroll on pop-up window in android?

我尝试了一段代码,但是没有显示垂直滚动条。 我的代码粘贴在下面:

     public void init() {
        popupButton = (Button) findViewById(R.id.textview1);
        popupText = new TextView(this);
        insidePopupButton = new Button(this);
        layoutOfPopup = new LinearLayout(this);
        LinearLayout lt=new LinearLayout(this);
        view=new ScrollView(this);
        insidePopupButton.setText("OK");
        popupText.setText("This is Popup Window.press OK to dismiss   it.");
        popupText.setBackgroundColor(Color.WHITE);
        popupText.setPadding(0, 0, 0, 20);
        layoutOfPopup.setOrientation(1);
        lt.addView(popupText);
        layoutOfPopup.addView(insidePopupButton,350,35);

        layoutOfPopup.setBackgroundColor(Color.BLACK);
        view.addView(lt);
        layoutOfPopup.addView(view);

在此处输入图片说明 先感谢您..:)

popupWindowScrollView都不能与android中的popupWindow结合使用。 悲伤但真实。

您需要通过以下方式添加视图:

LinearLayout linearLayout = new LinearLayout(this);

// add all your views to linearLayout(or RelativeLayout)
linearLayout.addView(popupText);
linearLayout.addView(insidePopupButton); 

// add linearLayout to ScrollView instance
view.addView(linearLayout);

// add ScrollView instance to main layout
layoutOfPopup.addView(view);

ScrollView是一个单元素容器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM