Android 如何在弹出窗口中显示texview底部的按钮?

Android 如何在弹出窗口中显示texview底部的按钮?,android,Android,我可以创建按钮和弹出窗口,但弹出窗口中的按钮显示在弹出窗口中文本的上方 我的意图是在弹出窗口的末尾显示该按钮,它是弹出窗口中文本的底部 我的代码是: public void init() { popupButton = (Button) findViewById(R.id.textview1); popupText = new WebView(this); popupText.setBackgroundResource(R.drawable.first);

我可以创建按钮和弹出窗口,但弹出窗口中的按钮显示在弹出窗口中文本的上方

我的意图是在弹出窗口的末尾显示该按钮,它是弹出窗口中文本的底部

我的代码是:

    public void init() {
    popupButton = (Button) findViewById(R.id.textview1);
    popupText = new WebView(this);
    popupText.setBackgroundResource(R.drawable.first);
    popupText.setBackgroundColor(Color.TRANSPARENT);
    popupText.setVerticalScrollBarEnabled(true);
    popupText.setHorizontalScrollBarEnabled(true);
    insidePopupButton = new Button(this);
    layoutOfPopup = new LinearLayout(this);
    insidePopupButton.setText("log out button");
    insidePopupButton.setBackgroundResource(R.drawable.myborder);
    LayoutParams lpView = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);

    layoutOfPopup.addView(insidePopupButton, lpView);

    String text = "<html><body style=\"text-align:justify\"> %s </body></Html>";
    String summary = "Like 'I am right, you are wrong', dominating or refusing to be dominated, all these games are played by the ego.Very often, we find the inauthentic self is what is at play. </body></html>";
    popupText.loadData(String.format(text, summary), "text/html", "utf-8");
    popupText.setBackgroundResource(R.drawable.first);
    layoutOfPopup.setOrientation(1);
    layoutOfPopup.addView(popupText);
    layoutOfPopup.setBackgroundResource(R.drawable.first);


    public void popupInit() {
    popupButton.setOnClickListener(this);
    insidePopupButton.setOnClickListener(this);
    popupMessage = new PopupWindow(layoutOfPopup, LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    popupMessage.setContentView(layoutOfPopup);

}
public void init(){
popupButton=(按钮)findViewById(R.id.textview1);
popupText=新的网络视图(此);
popupText.setBackgroundResource(R.drawable.first);
setBackgroundColor(Color.TRANSPARENT);
popupText.setVerticalScrollBarEnabled(true);
popupText.setHorizontalScrollBarEnabled(true);
insidePopupButton=新按钮(此按钮);
layoutOfPopup=新的线性布局(本);
setText(“注销按钮”);
insidePopupButton.setBackgroundResource(R.drawable.myborder);
LayoutParams lpView=新的LayoutParams(LayoutParams.MATCH_父项,
LayoutParams.WRAP_内容);
layoutOfPopup.addView(内部弹出按钮,lpView);
字符串文本=“%s”;
String summary=“就像‘我是对的,你是错的’,支配或拒绝被支配,所有这些游戏都是由自我玩的。通常,我们会发现不真实的自我才是真正的自我。”;
loadData(String.format(text,summary),“text/html”,“utf-8”);
popupText.setBackgroundResource(R.drawable.first);
layoutOfPopup.setOrientation(1);
layoutOfPopup.addView(popupText);
layoutOfPopup.setBackgroundResource(R.drawable.first);
public void popupInit(){
setOnClickListener(这个);
insidePopupButton.setOnClickListener(此);
popupMessage=新的PopupWindow(LayoutOffOpup,LayoutParams.MATCH_父项,
LayoutParams.MATCH_PARENT);
setContentView(layoutOfPopup);
}
输出:


尝试按以下不同顺序添加视图:

layoutOfPopup = new LinearLayout(this);
...
layoutOfPopup.addView(popupText);
...
layoutOfPopup.addView(insidePopupButton, lpView);

是的。它适用于高宽度和高高度设备。但是当我滚动弹出窗口以在小型设备中读取窗口上的文本时,按钮不会显示。