问题描述
我正与支持Android包。
我已经创建了一个对话框:
对话对话框=新的对话框(活动,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
因为我想在对话框中显示一个全屏幕,所以我申请的主题 Theme_Translucent_NoTitleBar_Fullscreen
来资讯科技及电讯;它的工作原理。
我有以下两个问题:
-
我想我的对话框显示像全屏幕依然,但留下顶部的动作条不能涵盖的,我应该用什么主题呢?
-
如何有一个灰色的颜色叠加也显示包括在对话框中的视图(假设我的第一qustion已解决)?
- 的唯一工作解决方案,我发现是基于片段来实现伪对话框。
- 在这种方法可能会造成一些困难做影子。至少,我没有做到这一点。
code样品怎么办(1):
公共类MyDialog扩展片段{
@覆盖
公共查看onCreateView(LayoutInflater充气,容器的ViewGroup,捆绑savedInstanceState){
// ...您的code
}
公共无效展(FragmentManager fragmentManager){
FragmentTransaction英尺= fragmentManager.beginTransaction();
字符串变量= MyDialog.class.getName();
ft.add(android.R.id.content,这一点,标签);
ft.commit();
}
私人无效驳回(){
FragmentTransaction英尺= getFragmentManager()的BeginTransaction()。
ft.remove(本);
ft.commit();
}
}
I am working with Android Support package.
I have created a dialog:
Dialog dialog = new Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
Since I would like the dialog show in a full screen, so I applied the theme Theme_Translucent_NoTitleBar_Fullscreen
to it & it works.
I have following two questions:
I would like my dialog to show like full screen still but leave the top ActionBar not be covered by it, what Theme should I use then?
How to have an gray color overlay to also show the view covered by the dialog (assume my 1st qustion has resolved)?
- The only working solution I found is to implement pseudo-dialog based on fragment.
- This approach might cause some difficulties to do shadow. At least, I didn't do that.
Code sample how to do (1):
public class MyDialog extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// ... your code
}
public void show(FragmentManager fragmentManager) {
FragmentTransaction ft = fragmentManager.beginTransaction();
String tag = MyDialog.class.getName();
ft.add(android.R.id.content, this, tag);
ft.commit();
}
private void dismiss() {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.remove(this);
ft.commit();
}
}
这篇关于显示对话框在我的情况几乎全屏幕(通过动作条和放大器;叠加)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!