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