带有ImageView的Android AlertDialog问题
我正在制作一个具有一个图像的自定义alertdialog。我面临的问题如下: 1) 对于屏幕较小的设备,此警报对话框似乎太大。aletdialog按钮离开屏幕(正极和负极按钮) 2) alertdialog将被绘制两次。ie有两个alertdialogs,一个在另一个上,我必须点击两次肯定按钮来关闭它们 以下是alertdialog的代码:-带有ImageView的Android AlertDialog问题,android,android-alertdialog,Android,Android Alertdialog,我正在制作一个具有一个图像的自定义alertdialog。我面临的问题如下: 1) 对于屏幕较小的设备,此警报对话框似乎太大。aletdialog按钮离开屏幕(正极和负极按钮) 2) alertdialog将被绘制两次。ie有两个alertdialogs,一个在另一个上,我必须点击两次肯定按钮来关闭它们 以下是alertdialog的代码:- AlertDialog.Builder alertdialog = new AlertDialog.Builder(
AlertDialog.Builder alertdialog = new AlertDialog.Builder(
Activity.this);
alertdialog.setTitle("Title ");
alertdialog.setMessage("The MEssage ");
LayoutInflater layoutinf= LayoutInflater.from(Activity.this);
final View view = layoutinf.inflate(R.layout.layoutfile, null);
alertdialog.setView(view);
alertdialog.setPositiveButton("Button1",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//do something
}
});
alertdialog.show();
任何提示都会有帮助
感谢您,第二个问题警报对话框应该是这样的:
AlertDialog.Builder alertdialog= new AlertDialog.Builder(this);
alertdialog.setTitle("Title");
alertdialog.setPositiveButton("OK", okListener);
alertdialog.setNegativeButton("Cancel", cancelListener);
AlertDialog alertdialogDlg = alertdialog.create();
alertdialogDlg.show();
public DialogInterface.OnClickListener okListener = new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//do something
}
};
您提供的详细信息无助于我们识别您的问题Hi Pragnani,对于问题1,alertdialog box正反按钮超出了小屏幕设备的屏幕范围。我们是否可以设置任何属性,以确保完整的alertdialog(包括图像和按钮)不会被裁剪。不要在xml中为视图及其子视图设置固定的高度和宽度。如果视图很复杂,请使用此FrameLayout fl=(FrameLayout)findViewById(android.R.id.custom);fl.addView(myView,新布局参数(匹配父项,包装内容));