显示片段作为对话或者作为通常活动 [英] Show fragment as a dialog or as a usual activity
问题描述
在我的应用我有一个被称为关于片段。在手持设备上我想这个片段看起来像一个平常的活动,但在平板电脑上我希望它是一个对话框。哪种方法pferred处理这种情况的$ P $?
In my app I've got a fragment which is called "About". On handhelds I want this fragment to look like a usual activity but on tablets I want it to be a dialog. Which way is preferred to handle this situation?
推荐答案
请为这个风格在你的 styles.xml
(二styles.xml文件,一个在值
文件夹中,另外在一个价值观大
文件夹),但你把价值观为大文件夹的样式从Theme.Dialog继承。然后让你的片段,使用该样式。该系统将完成剩余的工作。
Make a style for this in your styles.xml
(two styles.xml files, one in the values
folder, the other in a values-large
folder) but have the style you put in the values-large folder inherit from Theme.Dialog. Then have your fragment use that style. The system will take care of the rest.
另外,让你的类DialogFragment,然后要么嵌入到一个视图层次结构,或显示它作为一个对话框,在这里解释的:
Alternatively, make your class a DialogFragment, and then either embed it into a view hierarchy, or show it as a dialog, as explained here:
<一个href="http://developer.android.com/reference/android/app/DialogFragment.html#DialogOrEmbed">http://developer.android.com/reference/android/app/DialogFragment.html#DialogOrEmbed
这篇关于显示片段作为对话或者作为通常活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!