android - Custom AlertDialog ScrollView, too big in 2.3 missing ok button -
i have show info, instructions of how use program, i've chosen alertdialog using custom xml scrollview. tested in tablet, xperia neo , 2 virtual devices. in 3 of them goes good, in 2.3 small screen,the dialog big , has bug in visualization makes hard close. idea why? here code: xml scrollview:
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:textsize="10sp"> </textview> </scrollview>`
and code calling it:
alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage(r.string.msg_help) .setcancelable(false) .setview(layoutinflater.from(this).inflate(r.layout.dialog_scrollable,null)) .settitle(r.string.help_title) .setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { //do things } }); alertdialog alert = builder.create(); alert.getwindow().setlayout(layoutparams.wrap_content, layoutparams.wrap_content); alert.show();
here how looks: http://postimg.org/image/wvg61x0qv/
an alertdialog
makes content scrollable automatically if wouldn't fit on screen. instead of inflating custom xml layout, set text dialog builder.settext()
builder.setmessage()
.
alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage(r.string.msg_help) .setcancelable(false) .settitle(r.string.help_title) .setmessage(r.string.help) .setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { //do things } }); alertdialog alert = builder.create(); alert.show();
notice removed line alert.getwindow().setlayout()
because think it's useless.
Comments
Post a Comment