我有SingleFramgnetActivity,其目的只是保存和替换其中的片段.
布局看起来像这样:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".SingleFragmentActivity"
>
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
我正在替换FrameLayout中的Fragments.当我在Fragment布局上将fitsSystemWindows设置为true时,它没有响应.实际上它只在创建Activity时才有效,但是一旦我在FrameLayout中替换Fragment,就会忽略fitsSystemWindows参数,并且布局位于状态栏和导航栏下方.
我找到了一些带有自定义FrameLayout的solution,它使用了弃用的方法,但由于某些原因它不适用于我(与普通FrameLayout相同的结果),我也不喜欢使用弃用方法的想法.