Commit 2e3b7f56 authored by justin's avatar justin

解决fragment状态栏问题

parent 0a1fb5d8
package com.taobao.idlefish.flutterboostexample;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
public class FitSystemWindowFrameLayout extends FrameLayout {
public FitSystemWindowFrameLayout( @NonNull Context context) {
super(context);
}
public FitSystemWindowFrameLayout( @NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public FitSystemWindowFrameLayout( @NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public FitSystemWindowFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
WindowInsets result = super.dispatchApplyWindowInsets(insets);
if (!insets.isConsumed()) {
final int count = getChildCount();
for (int i = 0; i < count; i++)
result = getChildAt(i).dispatchApplyWindowInsets(insets);
}
return result;
}
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
super.addView(child, index, params);
ViewCompat.requestApplyInsets(child);
}
}
......@@ -5,7 +5,7 @@
android:orientation="vertical"
android:background="@android:color/white">
<FrameLayout
<com.taobao.idlefish.flutterboostexample.FitSystemWindowFrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment