How can I show my activity as a dialog in Android?(如何在 Android 中将我的活动显示为对话框?)
问题描述
我正在开发我的第一个 Android 应用程序,并且正在尝试为我的活动设置样式.最终,我希望我的活动看起来像一个对话.我在 AndroidManifest.xml
中使用以下代码为我的所有活动提供了 Theme.Dialog
样式:
.GalDude33 帮助我弄清楚如何实现我想要的.他的答案就是这个问题的答案.I am working on my first Android application, and am trying to style my activity. Ultimately, I would like for my activity to look the same as a dialog. I have given all my activities the Theme.Dialog
style using the following code in my AndroidManifest.xml
:
<application
android:icon="@drawable/group"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog">
</application>
This gives my activities the "floating" appearance and the borders of a dialog, but not the styled title. The title just has the same color and appearance as the general dialog background, not the "header" background and border as in a "real" dialog. Notice how in both examples the header has a nice border under it and in the second one, it has a gradient background.
Is there a way to make sure the title on my activity somehow inherits the system dialog title so as to effectively replicate the look of a dialog for my activity - in addition to the border and "float" which comes with the Theme.Dialog
style?
Note that I do not want to call my activity as a dialog from another, I just want it to LOOK like a dilaog, even when it is loaded in response to an intent as per my manifest's intent-filters.
ADD: Is there perhaps some way I can have my activity, when it spins up in onCreate()
, call some method to turn itself into an actual dialog? Keep in mind the activity still needs to be able to respond to intents from the system.
解决方案 After deciding to look at what I wanted to do, instead of how to do it specifically, I found a different approach. I reasked my question looking for approach ideas instead of implementation ideas here. GalDude33 helped me figure out how to achieve what I wanted. His answer there was the answer to this Q.
这篇关于如何在 Android 中将我的活动显示为对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Android 中将我的活动显示为对话框?


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01