【发布时间】:2015-09-30 08:29:07
【问题描述】:
我有一个应该显示全屏对话框的 Android 应用。我尝试了不同的解决方案,但似乎没有一个可行。 这是我的代码。 对话框布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_transparent" >
<!--declaration of other widgets -->
</RelativeLayout>
这是扩展对话框的类:
publicMyDialog(Context context) {
super(context, R.style.DialogTheme);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(R.layout.my_dialog);
this.setCancelable(true);
this.setCanceledOnTouchOutside(false);
this.getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND);
}
这是 R.style.DialogTheme 声明
<style name="DialogTheme" parent="android:Theme.Dialog">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">true</item>
</style>
现在显示对话框时,它不会填满整个屏幕。 如何让对话框占据整个屏幕?
【问题讨论】:
-
您可以将活动表示为对话框
标签: android dialog android-dialog