Code Monkey home page Code Monkey logo

Comments (10)

laobie avatar laobie commented on May 27, 2024

不在第一个的时候确实需要自己再调整一下的,参照我的处理,自己对界面做一点处理,这里只是给个用例,不能给出所有的用例

from statusbarutil.

laobie avatar laobie commented on May 27, 2024

@Chen-Sir 你可以再切换到 imageFragment 时给界面设置一个状态栏高度的偏移

from statusbarutil.

Chen-Sir avatar Chen-Sir commented on May 27, 2024

@laobie 它为什么往上移了一小段距离呢?这个地方不是很理解。

from statusbarutil.

laobie avatar laobie commented on May 27, 2024

@Chen-Sir 看到你的邮件了,明天我抽空看一下

from statusbarutil.

canhuah avatar canhuah commented on May 27, 2024

可以给你其他fragment的最上面添加一个View
<View
android:background="@color/main_red" //你想设置的颜色
android:layout_width="match_parent"
android:layout_height="@dimen/statusbar_height"/> //状态栏的高度

之后在values-v19 dimens.xml中定义statusbar_height = 25dp
在vlues 下定义statusbar_height = 0dp
意为API>=19以上高度为25dp(状态栏高度) 以下高度为0dp

from statusbarutil.

Chen-Sir avatar Chen-Sir commented on May 27, 2024

@laobie 嗯,我周末就搞定这个问题了,有点忙,没来及回复issues。本想推个PR,但想想问题也比较简单,就算了。上面那个方法,我看了并试了下,可以的,方法很好。不过我用的是另外一种方式。我修改了你的源码。
我再把我遇到的问题详细复述下:在5.0版本以上,在Sample的UseInFragmentActivity中(即在同一个activity中),从第一页切换到第二页时(setColor方法切换到setTranslucentForImageViewInFragment时),ImageFragment(第二页)界面整体往上移动了一点高度,在你的Sample中的表现是底部的BottomBar非常快速的上下抖动了一下,看样子是界面本来往上移了一点,但是又快速重绘了,占满了屏幕。以上问题,均保持UseInFragmentActivity中的代码不变,仅仅修改setStatusBar方法和调整ImageFragment位置

我的解决办法是:在StatusBarUtil类的setTransparentForWindow方法改为如下:

private static void setTransparentForWindow(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
        activity.getWindow()
            .getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

        Window window = activity.getWindow();
        ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
        View mChildView = mContentView.getChildAt(0);
        if (mChildView != null) {
            ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    return insets;
                }
            });
            ViewCompat.setFitsSystemWindows(mChildView, false);
            ViewCompat.requestApplyInsets(mChildView);
        }
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
       .........
       //不变
    }
}

这样,ImageFragment会立即适应屏幕,使用本库时,5.0版本以上不会发生闪动或者底部冒出一截空白view。经测试,修改代码后,并未影响Sample中其他示例的效果。

其实UseInFragmentActivity中的resetFragmentView方法逻辑可以加到StatusBarUtil中,我试过。这样用起来更傻瓜一点。不过也无所谓,自己加些逻辑也没问题。

from statusbarutil.

Chen-Sir avatar Chen-Sir commented on May 27, 2024

@canhuah 方法很好!谢谢!

from statusbarutil.

laobie avatar laobie commented on May 27, 2024

@Chen-Sir ok,你这样的使用看起来也不错,不知道切换过程中怎么样,昨天一开始和楼上那个哥们讨论时我也尝试在工具类上做修改,但是修改完了感觉效果还是差点,后来就想着把颜色状态栏的界面也当成图片界面处理,这样就少了切换的过程,整个 viewpager 的滑动很切换看起来都很好,而且管理起来也不错。
谢谢探讨~

from statusbarutil.

Chen-Sir avatar Chen-Sir commented on May 27, 2024

@laobie 嗯,我也觉得可以合为一起,少了切换过程。用起来也不用写什么判断逻辑了(迷之缩进毁一生233)。我主要是觉得Library这东西,用起来越简单越好。

from statusbarutil.

tt328307109 avatar tt328307109 commented on May 27, 2024

66666

from statusbarutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.