最近项目组code review让查看StatusBar.setTranslucent()这个方法到底是干嘛的,就看了下源码;
在android中查到的代码是
@ReactMethod
public void setTranslucent(final boolean translucent) {
final Activity activity = getCurrentActivity();
if (activity == null) {
FLog.w(ReactConstants.TAG, "StatusBarModule: Ignored status bar change, current activity is null.");
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
UiThreadUtil.runOnUiThread(
new GuardedRunnable(getReactApplicationContext()) {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void runGuarded() {
// If the status bar is translucent hook into the window insets calculations
// and consume all the top insets so no padding will be added under the status bar.
View decorView = activity.getWindow().getDecorView();
if (translucent) {