gpt4 book ai didi

android - 如何自定义对话框的标题布局

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:55:53 25 4
gpt4 key购买 nike

在 Android 中,是否可以自定义对话框的标题布局(图标 + 文本)布局?或者我可以只设置标题文本的自定义字符串值吗?

谢谢。

最佳答案

如果您为对话框和标题设置自定义布局,则可以更改对话框的标题。我只使用过这种方法来完全删除 header ,但这应该适用于自定义 header :

dialog = new Dialog(context);
Window window = dialog.getWindow();
window.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
dialog.setContentView(R.layout.my_dialog_layout);
window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_header);

这有点复杂(因为您还必须设置对话框的布局)但它比子类化对话框更容易。

关于android - 如何自定义对话框的标题布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1935257/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com