Reputation: 21
I use custom dialog in android. I want changed size custom dialog in all screen , But this is at all screen one size. I used 2 class for custom dialog :
this is class for show custom dialog:
public class mh_show_dialog {
public Button yes , no;
private TextView txt;
private Context context ;
final mh_alert_dialog dialog;
public mh_show_dialog(Context co)
{
this.context = co;
dialog = new mh_alert_dialog(context);
}
public void dialog_text(String message , String btn_yes , String btn_no , String image_title)
{
dialog.set_text(message,btn_yes,btn_no);
dialog.set_image(image_title);
yes = (Button) dialog.findViewById(R.id.alert_yes);
no = (Button) dialog.findViewById(R.id.alert_no);
txt = (TextView) dialog.findViewById(R.id.alert_msg);
no.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v) {
dialog_dismiss();
}
});
dialog.show();
}
public void dialog_dismiss()
{
dialog.dismiss();
}
public void False_visible_btn_no()
{
no.setVisibility(View.INVISIBLE);
}
}
Please help me.
Upvotes: 0
Views: 3913
Reputation: 1344
your problem is "I use custom dialog in android. I want changed size custom dialog in all screen ". you can do several things.
Change your layout file size.
You need to change the layout "R.layout.alert_dialog", and change the layout size according to your requirement. if you need more help, then show me your XML layout file.
Set Size at Runtime(In your DialogHelper java file) check this answer
updated answer.... if you want to get dynamic size Dialog box at different place , then you need to create a function in which you specify the height and width of your dialog box at run time.Use this function in your custom Dialog code, give size of width & height at run time.
public void showInfoAlertDialog(Context context, String message,int height, int width) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
// Setting Dialog Message
alertDialog.setMessage(message);
// Setting OK Button
alertDialog.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
// Showing Alert Message
AlertDialog alert = alertDialog.show();
TextView messageText = (TextView) alert
.findViewById(android.R.id.message);
messageText.setGravity(Gravity.CENTER);
alert.show();
alertDialog.getWindow().setLayout(width, hight);
}
Update 4:
now change your code at two location,
Upvotes: 1