我尝试使用DialogFragment
创建简单的FullScreen对话框,但UI与状态栏冲突
从片段中调用它时会出现此问题(TabLayout的片段)如果我从活动中调用它,它可以正常工作。
如何解决任何问题......
我正在使用此代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="@+id/button_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="@android:color/white"
app:srcCompat="@drawable/ic_birthday_cross" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Dialog title"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:textColor="@android:color/white" />
<Button
android:id="@+id/button_action"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:text="Action"
android:textColor="@android:color/white" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:text="Full Screen Dialog" />
</android.support.v4.widget.NestedScrollView>
此对话框片段从Tablayout的片段
调用FragmentManager fragmentManager = getFragmentManager(); //getSupportFragmentManager();
BirthdayDialogFragment newFragment = new BirthdayDialogFragment();
FragmentTransaction transaction = null;
if (fragmentManager != null) {
transaction = fragmentManager.beginTransaction();
}
assert transaction != null;
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.add(android.R.id.content, newFragment).addToBackStack(null).commit();