如何使用图像视图和按钮自定义对话框片段标题?
How to customize dialog fragment title with image view and button?
我有一个对话片段,我需要在其中显示通话记录列表项点击人员的通话记录详细信息。我需要显示显示照片和按钮而不是对话框片段的标题。我还尝试删除标题并放置照片和按钮,但宽度包裹了内容并且对话框尺寸缩小了。我需要宽度来填充 parent,或者匹配 parent activity.
我的问题已解决。在我尝试修复 xml 中的布局之前,现在我在对话框片段的 onStart 方法中添加了布局宽度和高度,并使用 FEATURE_NO_TITLE 标志删除了标题。这是代码:
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
// request a window without the title
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
@Override
public void onStart() {
super.onStart();
// safety check
if (getDialog() == null) {
return;
}
int dialogWidth = --- // specify a value here
int dialogHeight = --- // specify a value here
getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
}
我有一个对话片段,我需要在其中显示通话记录列表项点击人员的通话记录详细信息。我需要显示显示照片和按钮而不是对话框片段的标题。我还尝试删除标题并放置照片和按钮,但宽度包裹了内容并且对话框尺寸缩小了。我需要宽度来填充 parent,或者匹配 parent activity.
我的问题已解决。在我尝试修复 xml 中的布局之前,现在我在对话框片段的 onStart 方法中添加了布局宽度和高度,并使用 FEATURE_NO_TITLE 标志删除了标题。这是代码:
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
// request a window without the title
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
@Override
public void onStart() {
super.onStart();
// safety check
if (getDialog() == null) {
return;
}
int dialogWidth = --- // specify a value here
int dialogHeight = --- // specify a value here
getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
}