我試了一段代碼,但它不顯示垂直滾動條。我的代碼粘貼如下:如何在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);
預先感謝您.. :)
謝謝kelvincer。我得到滾動條,但'確定'按鈕關閉彈出窗口不顯示彈出 – Vishwak 2015-01-15 18:28:43
將您的按鈕添加到linearLayout – kelvincer 2015-01-15 18:33:28
按鈕顯示在彈出窗口的頂部,而不是向下當我添加到主要線性佈局只有...我需要在彈出窗口的底部顯示我的Ok按鈕.. – Vishwak 2015-01-15 18:36:53