[英]TextView inside an alert dialog won't scroll down
我正在從網站上獲取數據並將其放置在文本視圖中,以便可以使用setGravity(Gravity.CENTER)將其居中。 但是,當我將文本視圖放置在警報對話框中時,我無法再向下滾動以查看消息的結尾。 有人可以幫我解決這個問題嗎? 謝謝
TextView msg1=new TextView(Welcome.this);
//Takes data from a website
msg1.setText(Html.fromHtml(getText("http://www.cellphonesolutions.net/welcome-en")));
msg1.setGravity(Gravity.CENTER);
LinearLayout dialogLayout = new LinearLayout(Welcome.this);
dialogLayout.addView(msg1);
dialogLayout.setOrientation(LinearLayout.VERTICAL);
AlertDialog welcome = new AlertDialog.Builder(Welcome.this).create();
welcome.setView(dialogLayout);
welcome.setButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//rest of the code....
您可以嘗試更改代碼,如下所示:
dialogLayout.addView(msg1);
dialogLayout.setOrientation(LinearLayout.VERTICAL);
AlertDialog welcome = new AlertDialog.Builder(Welcome.this).create();
ScrollView scrollPane = new ScrollView(this);
scrollPane.addView(dialogLayout);
welcome.setView(scrollPane);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.