laobie / StatusBarUtil

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

fragment+viewpager问题 #83

Closed ruhaly closed 7 years ago

ruhaly commented 7 years ago

fragment+viewpager的时候,首次没效果,只有切换tab之后才有效果,咋回事呢

ruhaly commented 7 years ago

首次是不走 @Override public void onPageSelected(int position) { showToast(""+position); if (position == 0) { setTranslucentForImageViewInFragment(MainActivity.this, null); } else { if (isFullScreen) { resetFragmentView(fragments.get(position)); } StatusBarUtil.setColor(MainActivity.this, getResources().getColor(R.color.colorPrimary), 255); } } 的, 我又把 setTranslucentForImageViewInFragment(MainActivity.this, null); 这段代码放到oncreate里面还是没用

laobie commented 7 years ago

看以前的issue

ruhaly commented 7 years ago

你说的是#80 么,不一样啊,

laobie commented 7 years ago

一样啊,切 tab 都不用处理了

laobie commented 7 years ago

你看 issue 中的讨论啊 大哥 @ruhaly

ruhaly commented 7 years ago

可以给你其他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

这个view是加到fragment的布局里面?

laobie commented 7 years ago

嗯 不行我给你们写个 demo 吧

ruhaly commented 7 years ago

沉侵式图片的那个fragment么

laobie commented 7 years ago

自己先思考下再提问吧

laobie commented 7 years ago

@ruhaly 代码更新了 自己看看我的提交吧

ruhaly commented 7 years ago

恩 好,谢谢了

laobie commented 7 years ago

@ruhaly 更新了英文的 README 详细介绍了在 Fragment 中使用的方法,对应的 Demo 也更新了,可以下载查看。如果没疑问了,请关闭此 issue。

ruhaly commented 7 years ago

遇到一奇怪的问题:我在其他fragment的布局里面都加了

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

<View
    android:layout_width="match_parent"
    android:layout_height="@dimen/statusbar_height"
    android:layout_above="@+id/content"
    android:background="@color/colorPrimary" />

Mainactivity 里面 StatusBarUtil.setTranslucentForImageViewInFragment(activity, needOffsetView); 其他没写,但是 界面并没有上移, image image

laobie commented 7 years ago

跑 demo demo 正常的话自己处理 我不会给你写代码

ruhaly commented 7 years ago

代码肯定我自己写,但是不知道错在哪儿,改写的也好像都写了

laobie commented 7 years ago

再说一次 运行 demo 下载 apk 装到手机上 跑起来 好了 你的提问我不会再回复了

ruhaly commented 7 years ago

行吧,我再看看