<tfoot id='hkpEc'></tfoot>
<i id='hkpEc'><tr id='hkpEc'><dt id='hkpEc'><q id='hkpEc'><span id='hkpEc'><b id='hkpEc'><form id='hkpEc'><ins id='hkpEc'></ins><ul id='hkpEc'></ul><sub id='hkpEc'></sub></form><legend id='hkpEc'></legend><bdo id='hkpEc'><pre id='hkpEc'><center id='hkpEc'></center></pre></bdo></b><th id='hkpEc'></th></span></q></dt></tr></i><div id='hkpEc'><tfoot id='hkpEc'></tfoot><dl id='hkpEc'><fieldset id='hkpEc'></fieldset></dl></div>

  • <legend id='hkpEc'><style id='hkpEc'><dir id='hkpEc'><q id='hkpEc'></q></dir></style></legend>
        <bdo id='hkpEc'></bdo><ul id='hkpEc'></ul>

      1. <small id='hkpEc'></small><noframes id='hkpEc'>

        Android 自定义 PopupWindow/Dialog

        时间:2023-08-31
                <tbody id='tTIQB'></tbody>

              <small id='tTIQB'></small><noframes id='tTIQB'>

                <bdo id='tTIQB'></bdo><ul id='tTIQB'></ul>

              • <i id='tTIQB'><tr id='tTIQB'><dt id='tTIQB'><q id='tTIQB'><span id='tTIQB'><b id='tTIQB'><form id='tTIQB'><ins id='tTIQB'></ins><ul id='tTIQB'></ul><sub id='tTIQB'></sub></form><legend id='tTIQB'></legend><bdo id='tTIQB'><pre id='tTIQB'><center id='tTIQB'></center></pre></bdo></b><th id='tTIQB'></th></span></q></dt></tr></i><div id='tTIQB'><tfoot id='tTIQB'></tfoot><dl id='tTIQB'><fieldset id='tTIQB'></fieldset></dl></div>

                  <tfoot id='tTIQB'></tfoot><legend id='tTIQB'><style id='tTIQB'><dir id='tTIQB'><q id='tTIQB'></q></dir></style></legend>

                1. 本文介绍了Android 自定义 PopupWindow/Dialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试获得一个完全自定义的 Dialog 或 PopupWindow,没有任何默认的 Android UI 控件(标题、背景、按钮等).

                  I'm trying to get a completely custom Dialog or PopupWindow, without any of the default Android UI controls (title, background, buttons, whatever).

                  这可能吗?我花了几个小时寻找这个,但没有运气......这似乎应该很容易实现,但我找不到它.

                  Is this possible at all? I've spent hours searching for this, but no luck... It seems like this should be easily possible, but I can't find it.

                  最好是通过从 XML 扩展视图来实现,但在这一点上,任何可以正常工作的东西都会很好.

                  Preferably this would be by inflating a View from XML, but at this point anything that would just work would be nice.

                  谢谢.

                  推荐答案

                  我采取的步骤:

                  1. 创建一个扩展Dialog的类.
                  2. 在 onCreate 中,调用 setContentView(x, y),其中 x 是您的 R.layout,y 是 R.style.popupStyle(见下文).
                  3. 在您的 res/values/style.xml 中,您需要覆盖默认的 DialogWindow 样式.我尝试制作一种以该样式为父样式的样式,但这仍然没有清除所有默认值.所以我检查了 Android git 树并得到了默认样式,然后复制粘贴了它.就是这个:
                  1. Create a class extending Dialog.
                  2. In the onCreate, call setContentView(x, y) with x being your R.layout and y being R.style.popupStyle (see below).
                  3. In your res/values/style.xml, you need to override the default DialogWindow style. I tried just making a style that has this one as its parent, but that still didn't clear all defaults. So I checked the Android git tree and got the default style, and just copy-pasted it. This is the one:

                  <style name="Theme.Dialog">
                      <item name="android:windowFrame">@null</item>
                      <item name="android:windowTitleStyle">@android:style/DialogWindowTitle</item>
                      <item name="android:windowBackground">@android:drawable/panel_background</item>
                      <item name="android:windowIsFloating">true</item>
                      <item name="android:windowContentOverlay">@null</item>
                      <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
                      <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
                  </style>

                  您会遇到一些错误,只需从官方 Android 的 styles.xml 和 Themes.xml 文件中复制更多内容即可解决这些错误.这是我的 styles.xml 文件的内容:http://pastebin.com/RRR15YYS

                  You'll get a few errors, just solve them by copying more stuff from the official Android styles.xml and themes.xml files. Here's the contents of my styles.xml file: http://pastebin.com/RRR15YYS

                  这只是给你一个白色的弹出窗口,没有边框,什么都没有.开始定制.:)

                  That just gives you a white popup, no borders, nothing. Start customizing. :)

                  感谢 mbaird 让我走上正轨.

                  Thanks to mbaird for putting me on the right track.

                  [edit] 我需要再次查找自己的答案,并且我花了至少十分钟搜索官方的 android 样式/主题文件,所以在这里,以供将来参考:styles.xml 和 themes.xml.

                  [edit] I needed to look up my own answer again, and I spent at least ten minutes searching the official android styles/themes files, so here they are, for future reference: styles.xml and themes.xml.

                  这篇关于Android 自定义 PopupWindow/Dialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Android 中创建完全自定义的 Dialogue/Popup(更 下一篇:Android 无边框对话框

                  相关文章

                  最新文章

                  <tfoot id='riQSJ'></tfoot>
                  <legend id='riQSJ'><style id='riQSJ'><dir id='riQSJ'><q id='riQSJ'></q></dir></style></legend>
                    <bdo id='riQSJ'></bdo><ul id='riQSJ'></ul>
                    <i id='riQSJ'><tr id='riQSJ'><dt id='riQSJ'><q id='riQSJ'><span id='riQSJ'><b id='riQSJ'><form id='riQSJ'><ins id='riQSJ'></ins><ul id='riQSJ'></ul><sub id='riQSJ'></sub></form><legend id='riQSJ'></legend><bdo id='riQSJ'><pre id='riQSJ'><center id='riQSJ'></center></pre></bdo></b><th id='riQSJ'></th></span></q></dt></tr></i><div id='riQSJ'><tfoot id='riQSJ'></tfoot><dl id='riQSJ'><fieldset id='riQSJ'></fieldset></dl></div>

                      <small id='riQSJ'></small><noframes id='riQSJ'>