laobie / StatusBarUtil

A util for setting status bar style on Android App.
http://t.cn/Rq746Kb
Apache License 2.0
8.81k stars 1.72k forks source link

如果是查看大图界面,如何延伸到状态栏 #6

Closed chenshuhong closed 8 years ago

chenshuhong commented 8 years ago

`<?xml version="1.0" encoding="utf-8"?> <FrameLayout android:id="@+id/fl" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.ViewPager android:id="@+id/vPager" android:layout_width="match_parent" android:layout_height="match_parent" />

` 这是我的查看大图界面布局,viewpager里是包含photoview的fragment,我用StatusBarUtil.setTransparent(this);

laobie commented 8 years ago

我们项目里面这个界面 目前是没延伸到状态栏,而是用了一个全屏界面,你提到的这个我有空看下,最近可能要重写一个这界面

chenshuhong commented 8 years ago

好的,期待

niorgai commented 8 years ago

@chenshuhong 你好, 我想问下 StatusBarUtil.setTransparent(this); 这个方法不是可以延伸到状态栏吗?

laobie commented 8 years ago

这个是可以的,不过针对的是根布局才行,但是@chenshuhong 这个比较特殊,是在fragment里面的

chenshuhong commented 8 years ago

@niorgai 整个界面是延伸到状态栏了,但是包含fragment的viewpager还是顶不上去

niorgai commented 8 years ago

@laobie 其实我也做了一个状态栏的兼容类, StatusBarCompat 类, 前面尝试过跟你差不多的方法, 但是发现 fitsSystemWindow 这个属性也没有想象中那么智能, 最后我用 marginTop 来模拟这个属性, 发现兼容性不错, 比如 CoordinatorLayout 的问题也能解决. 不知道你对这种方法有什么看法~ 我在项目中也是这样用的,看起来可以解决这边 viewpager 的问题

laobie commented 8 years ago

看起来不错,等我用空我研究下你的代码,主要是 CoordinatorLayoutDrawerLayout好像都重写了 fitsSystemWindow 方法,还没研究他们具体的源码= =

laobie commented 8 years ago

@niorgai 你这个全透明的时候有问题啊= = 你看下哈 image

niorgai commented 8 years ago

@laobie 我主要是想解决同一个 Activity 里面不同 Fragment 在全屏和非全屏之间切换的问题, 在全屏的时候 demo 里面没有切换成图片, 所以看起来怪怪的~ 没问题啦. MarginCompatActivity 是最后的总结啦.

laobie commented 8 years ago

酱紫= =理解了

chenshuhong commented 8 years ago

今晚睡前看了下,发现其实很简单就能让他延伸到状态栏 ` @Override

protected void setStatusBg() {
    StatusBarUtil.setTransparent(this);
    ViewGroup rootView = (ViewGroup) ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
    rootView.setFitsSystemWindows(false);
}`

让他fitsystemwindows设为false就行了,想太复杂了,不过小缺点是如果你有其他布局都会往上偏移状态栏高度的距离

laobie commented 8 years ago

@chenshuhong 最新的1.2.0 版本可能解决了这个问题,你可以看看