TextView inside an alert dialog won't scroll down
I am taking data from a website and placing inside of a text view so that I can center it using setGravity(Gravity.CENTER). However when i place the text view inside of the alert dialog I can no longer scroll down to see the end of my message. Can someone help me with this problem? Thank You
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();
welcom开发者_如何学编程e.setView(dialogLayout);
welcome.setButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//rest of the code....
You can try changing the code like this:
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);
精彩评论