New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample “UseInFragmentActivity”,ImageFrament不在viewpager的第一页时,切换到ImageFrament整个屏幕往上移动了一个状态栏高度 #53
Comments
不在第一个的时候确实需要自己再调整一下的,参照我的处理,自己对界面做一点处理,这里只是给个用例,不能给出所有的用例 |
@Chen-Sir 你可以再切换到 imageFragment 时给界面设置一个状态栏高度的偏移 |
@laobie 它为什么往上移了一小段距离呢?这个地方不是很理解。 |
@Chen-Sir 看到你的邮件了,明天我抽空看一下 |
可以给你其他fragment的最上面添加一个View 之后在values-v19 dimens.xml中定义statusbar_height = 25dp |
@laobie 嗯,我周末就搞定这个问题了,有点忙,没来及回复issues。本想推个PR,但想想问题也比较简单,就算了。上面那个方法,我看了并试了下,可以的,方法很好。不过我用的是另外一种方式。我修改了你的源码。 我的解决办法是:在 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) {
.........
//不变
}
} 这样, 其实 |
@canhuah 方法很好!谢谢! |
@Chen-Sir ok,你这样的使用看起来也不错,不知道切换过程中怎么样,昨天一开始和楼上那个哥们讨论时我也尝试在工具类上做修改,但是修改完了感觉效果还是差点,后来就想着把颜色状态栏的界面也当成图片界面处理,这样就少了切换的过程,整个 viewpager 的滑动很切换看起来都很好,而且管理起来也不错。 |
@laobie 嗯,我也觉得可以合为一起,少了切换过程。用起来也不用写什么判断逻辑了(迷之缩进毁一生233)。我主要是觉得Library这东西,用起来越简单越好。 |
66666 |
ImageFrament不放在viewpager的第一页时,切换到ImageFrament时整个界面往上移动了一个状态栏高度(底部冒出一个高度为状态栏高度的白色的view)。添加fragment代码如下:
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new ImageFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
并且UseInFragmentActivity的setStatusBar方法改为如下:
protected void setStatusBar() {
StatusBarUtil.setColor(UseInFragmentActivity.this, ContextCompat.getColor(this, R.color.colorAccent), 0);
其他代码未变动。
The text was updated successfully, but these errors were encountered: