so i'm creating custom dialog box should appear after required button pressed. however, when text long, textview goes out of screen. tried find solution this, unsuccessfully. hope me, guys. thanks. here xml code dialog box:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center" android:layout_margintop="20dp" android:layout_marginleft="20dp" android:layout_marginright="20dp"> <scrollview android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:id="@+id/txt_dia" android:layout_height="match_parent" android:layout_width="match_parent" android:textsize="16sp" android:layout_gravity="center" android:textcolor="@color/black"/> </scrollview> <button android:id="@+id/btn_back" android:layout_height="40dp" android:layout_width="100dp" android:clickable="true" android:text="@string/bck" android:textstyle="bold" android:layout_gravity="left"/> </linearlayout> thanks :)
dialog class:
import android.app.activity; import android.app.dialog; import android.os.bundle; import android.view.view; import android.view.window; import android.widget.button; import android.widget.textview; public class customdialogclass extends dialog implements android.view.view.onclicklistener { public activity c; public dialog d; public button back; private textview strongheads; private string text = ""; public customdialogclass(activity a) { super(a); this.c = a; } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.custom_dialog); strongheads = (textview) findviewbyid(r.id.txt_dia); //strongheads.setmovementmethod(new scrollingmovementmethod()); if(text.equalsignorecase("")){ strongheads.settext(text); } strongheads.settext(text); = (button) findviewbyid(r.id.btn_back); back.setonclicklistener(this); } @override public void onclick(view v) { dismiss(); } public void changetext(string txt){ this.text= txt; } }
Comments
Post a Comment