有没有办法使自定义对话框的标题部分不可见?
只是一个简单的问题,不知道如何做。有谁知道如何/是否可以做到这一点?
原因:我只想要一个没有分区的实体对话框,因为它在我的应用程序中看起来更好一点。
编辑
public void showCustomDialog() {
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.customdialog);
TextView thisText = (TextView) dialog.findViewById(R.id.customDialogThisText);
thisText.setText("This");
TextView thatText = (TextView) dialog.findViewById(R.id.customDialogThatText);
thatText.setText("That");
ImageView image = (ImageView) dialog.findViewById(R.id.customDialogImageView);
image.setImageResource(R.drawable.icon);
//Crashes the program with an AndroidRuntimeError
//dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
dialog.show();
}
Just a simple problem without any idea of how to do it. Does anyone know how/if this can be done?
Reason: I just want one solid dialog box with no partitions as it looks a little better in my application.
EDIT
public void showCustomDialog() {
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.customdialog);
TextView thisText = (TextView) dialog.findViewById(R.id.customDialogThisText);
thisText.setText("This");
TextView thatText = (TextView) dialog.findViewById(R.id.customDialogThatText);
thatText.setText("That");
ImageView image = (ImageView) dialog.findViewById(R.id.customDialogImageView);
image.setImageResource(R.drawable.icon);
//Crashes the program with an AndroidRuntimeError
//dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
dialog.show();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要不调用 setTitle() 就不会出现标题,如下所示:
Just don't call setTitle() and there will be no title, like that:
只需致电
dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
在设置对话框的视图之前
dialog.setContentView(R.layout.customdialog);
Just call
dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
before setting the view of the dialog by
dialog.setContentView(R.layout.customdialog);