具有默认对话框外观和感觉的自定义对话框 - 这可能吗?

发布于 2024-12-28 17:38:20 字数 1337 浏览 2 评论 0原文

澄清:我希望所有自定义对话框看起来像系统默认对话框:例如,当用户使用 htc sense 时,对话框应匹配 htc sense 对话框样式,当用户使用三星官方自定义对话框时,对话框应该看起来像这样。我想尽可能地本土化。我知道可以修改对话框,但我正在寻找一种方法来引用系统使用的样式并用它创建对话框。

我拥有的:

在此处输入图像描述

我想要实现的目标:< /strong>

在此处输入图像描述

我用 dialog.setContentView(... 调用的对话框布局代码)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@android:style/Theme.Dialog"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/listView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip" >
</ListView>

</LinearLayout>

如您所见,设置style="@android:style/Theme.Dialog 没有帮助。有什么想法可能有帮助吗?

(我很熟悉已经有这样一个问题:https://stackoverflow.com/questions/6746535/ android-custom-dialog-but-with-look-and-feel-of-default-one 但没有可接受的答案)

For clarification: I want all the custom dialogs to look like system default dialogs: for example, when user is using htc sense, the dialog should match htc sense dialog style, when user is using samsung with official customasation, the dialog should look like it. I want to go as native as possible. I am familiar that there are possibilities to modify the dialog, but I'm looking for a way to reference to the style the system uses and create a dialog with that.

What I have:

enter image description here

What I would like to achieve:

enter image description here

Code for my dialog layout which I invoke with dialog.setContentView(...):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@android:style/Theme.Dialog"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/listView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip" >
</ListView>

</LinearLayout>

As you can see setting the style="@android:style/Theme.Dialog isn't helping. Any ideas what might be helping?

(I am familiar that there is already such a question: https://stackoverflow.com/questions/6746535/android-custom-dialog-but-with-look-and-feel-of-default-one but there isn't an accepted answer)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不会写诗 2025-01-04 17:38:20

如果您希望出现的对话框仅用于您的应用程序目的,请按照以下步骤操作:

查看此图像,我已创建此图像以保存图像或将其发布到其他方式。

在此处输入图像描述

我已根据我的要求创建了 xml 布局。如果您想添加问题中所解释的列表视图,那么您必须在对话框的内容中手动实现该行为。这种布局的方法您必须实现具有该单选按钮和文本的自定义 ListView。并且还有一些 Java 代码根据该选择执行操作。

有了它,您就可以实现您想要的目标。

享受。 :)

If you want the dialog that appear just for your application purpose then follow this:

See this image i have create this one to save Image or Post it to different way.

enter image description here

I have created the xml layout as per my requirement. If you want to add the list view as you have explained in to the question then you have to manualy implement that behaviour in the content of the dialog. Means for such layour You have to implement the Custom ListView that have that radio button and text. And also have some Java code to do action according to that selection.

With that you can acheive as you want.

Enjoy. :)

旧城空念 2025-01-04 17:38:20

您可以为 一个 UI 构建一个看起来像本机的对话框,但是当另一个用户有其他 ROM/修改过的 UI 时,那么该对话框看起来不像本机对话框。没有内置功能来访问系统对话框资源并仅从本机布局填充所有对话框。

You can build a native-look like dialog for one UI, but when another user has some other ROM/modified UI, then the dialog doesn't look like a native one to hem/her. There isn't a built in functionality, to access system dialog resources and populate all dialogs from native layouts only.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文