Giter Site home page Giter Site logo

statusbarutil's Introduction

StatusBarUtil

996.icu

Android Arsenal

Download

A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4).

中文版点我

Sample

Download StatusBarUtil-Demo

ChangeLog

CLICK ME

Usage

  1. Add the dependencies to your build.gradle file, StatusBarUtil is avaiable in JCenter:

    compile 'com.jaeger.statusbarutil:library:1.5.1'

    I fixed typo, change "statusbaruitl" to "statusbarutil", please notice this.

  2. Call method you need after setContentView(), such as :

    setContentView(R.layout.main_activity);
    ...
    StatusBarUtil.setColor(MainActivity.this, mColor);
  3. If you use this util in a page which containing a DrawerLayout, you need add android:fitsSystemWindows="true" for DrawerLayout in your layout XML:

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">
    
        ...
    
    </android.support.v4.widget.DrawerLayout>
  4. Set color for swipe back page

    Recommend using with bingoogolapple/BGASwipeBackLayout-Android: Android Activity 滑动返回

    StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)
  5. All statusBarAlpha value you set should between 0 ~ 255

  6. How to use in Fragment, please read UseInFragmentActivity.java

    Handle all Fragments in ViewPager as ImageViewFragment, add a fake View in your Fragment layout as StatusBar :

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <View
            android:id="@+id/fake_statusbar_view"
            android:layout_width="match_parent"
            android:layout_height="@dimen/statusbar_view_height"
            android:background="@color/colorPrimary"/>
    
        <TextView
            android:id="@+id/tv_title"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:background="@color/colorPrimary"
            android:gravity="center"
            android:text="@string/app_name"
            android:textColor="@color/white"
            android:textSize="24sp"/>   
    </LinearLayout>

    The fake StatusBar View height value statusbar_view_height defined in dimens.xml

    ~ values-v19/dimens.xml
    
    <dimen name="statusbar_view_height">25dp</dimen>
    
    ~ values/dimens.xml
    
    <dimen name="statusbar_view_height">0dp</dimen>

    When you change StatusBarColor :

    mFakeStatusBar.setBackgroundColor(color);

    Then in the Activity which contains ViewPage, just invoke

    StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this, null);

    Please read UseInFragmentActivity.java

Features

  • Set status bar color

    StatusBarUtil.setColor(Activity activity, int color)

  • Set status bar translucent

    StatusBarUtil.setTranslucent(Activity activity, int statusBarAlpha)

  • Set status bar transparent

    StatusBarUtil.setTransparent(Activity activity)

  • Set status bar color for DrawerLayout

    StatusBarUtil.setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color)

  • Set translucent status bar for using ImageView as head view page

      StatusBarUtil.setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView)

  • Set Light or Dark mode

      StatusBarUtil.setLightMode(Activity activity)
      StatusBarUtil.setDarkMode(Activity activity)
    

  • Use in fragment

  • Set color for swipe back page

      StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)

  • Pass statusBarAlpha param when necessary to change your status bar alpha, which is 112 by default.

License

Copyright 2016 Jaeger Chen

Licensed under the Apache License, Version 2.0 (the "License");	you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

statusbarutil's People

Contributors

bruce3x avatar dvdandroid avatar fingerart avatar forsail avatar laobie avatar luigibaute avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

statusbarutil's Issues

What if below 4.4?

Obviously a product currently still has a lot of users whose android version is below 4.4…

奇怪的问题

demo 中 ImageStatusBarActivity,现有的XML外面在包一层任意的根节点(ps:LinearLayout、RelativeLayout),在N5手机(6.0)上状态栏看起来就不是透明的,因为猴子图片没有顶上去,除非新加的根节点设置这张猴子图片。
那么我想问的是 是什么造成原有的图片没有match_parent呢 明明是这么设置的。。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent"
android:orientation="vertical">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_monkey">

    <Button
        android:id="@+id/btn_change_background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="bottom|center_horizontal"
        android:layout_margin="16dp"
        android:text="Change Background" />

    <SeekBar
        android:id="@+id/sb_change_alpha"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/btn_change_background"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp" />

    <TextView
        android:id="@+id/tv_status_alpha"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/sb_change_alpha"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_horizontal"
        android:textColor="@color/colorAccent"
        android:textSize="36sp" />
</RelativeLayout>

</LinearLayout>

使用DrawerLayout侧滑出来的界面布局上移了,下面是布局代码

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/id_drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<com.zhy.autolayout.AutoLinearLayout
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.zhy.autolayout.AutoRelativeLayout
        android:layout_width="match_parent"
        android:layout_height="108px"
        android:background="@color/white">

        <com.zhy.autolayout.AutoLinearLayout
            android:id="@+id/btn_siding"
            android:layout_width="72px"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:gravity="center_vertical">
            <Button
                android:layout_width="38px"
                android:layout_height="39px"
                android:background="@drawable/personal"
                android:onClick="OpenLeftMenu"
                android:layout_marginStart="10dp"
                android:layout_centerVertical="true"
                android:layout_alignParentStart="true" />
        </com.zhy.autolayout.AutoLinearLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/black"
            android:textSize="36px"
            android:text="@string/home_title"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"/>
    </com.zhy.autolayout.AutoRelativeLayout>
    <include layout="@layout/activity_bottom"/>
    <FrameLayout
        android:id="@+id/home_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">
    </FrameLayout>
</com.zhy.autolayout.AutoLinearLayout>


<fragment
    android:id="@+id/id_left_menu"
    android:name="com.bagevent.home.fragment.MenuLeftFragment"
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:tag="LEFT" />

</android.support.v4.widget.DrawerLayout>

DrawerLayout下当用两个FrameLayout时setColorForDrawerLayout()函数会无效,无法变色

用Fragment替换DrawerLayout下的content和drawer时,如果下面是FrameLayout就没办法换颜色,需替换成LinearLayout才能变色
像下面这样才行,如果是FrameLayout或RelativeLayout就会错乱

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" />

    <LinearLayout
        android:id="@+id/drawer"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:orientation="vertical" />
</android.support.v4.widget.DrawerLayout>

下面函数只做了LinearLayout的判断,木有FrameLayout等的判断

public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color, int statusBarAlpha)
.....
// 内容布局不是 LinearLayout 时,设置padding top
        if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
            contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
        }
.....

MEIZU手机上setRootView报错

Caused by: java.lang.NullPointerException
at com.jaeger.library.StatusBarUtil.setRootView(StatusBarUtil.java:416)
at com.jaeger.library.StatusBarUtil.setColor(StatusBarUtil.java:56)
at com.jaeger.library.StatusBarUtil.setColor(StatusBarUtil.java:31)

ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);

rootView 空指针,不知道是不是魅族手机改变了根布局id

能否兼容右滑删除

如果activity加了进入、退出动画,或者添加了右滑删除手势,体验不是很好,因为状态栏是独立而存在的。可否优化?

设置状态栏透明后,根布局的 padding 属性不生效

在代码中设置状态栏透明后

        StatusBarUtil.setTranslucent(this);

or

        StatusBarUtil.setTranslucent(this, 0);

此 activity 对应的布局文件中根布局的 padding 属性不生效

  • 设备:Nexus 5
  • 系统:Android 5.1.1
  • 根布局:LinearLayout

Fragment 中可以实现吗

我现在遇到一个问题, 我在activity使用底部导航栏,然后再首页的fragment中 最上面的图片要做沉浸, 我试了你的方法, 没有实现。 求大神指教

Sample “UseInFragmentActivity”,ImageFrament不在viewpager的第一页时,切换到ImageFrament整个屏幕往上移动了一个状态栏高度

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);

    //isFullScreen = true;
    //StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this,0, null);
}

其他代码未变动。

Fragment 其中一个界面头部使用imageview,但是无法延伸至状态栏。

效果图:
image

界面布局:

<com.zhy.autolayout.AutoLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.zhy.autolayout.AutoRelativeLayout
    android:layout_width="match_parent"
    android:layout_height="180dp"
    android:id="@+id/ll_img">

    <ImageView
        android:id="@+id/banner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"/>

    <com.zhy.autolayout.AutoRelativeLayout
        android:id="@+id/rl_off"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp">

        <com.zhy.autolayout.AutoLinearLayout
            android:id="@+id/manager_back"
            android:layout_width="90px"
            android:layout_height="70px"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:layout_marginStart="6dp"
            android:layout_marginTop="9dp">
            <ImageView
                android:layout_width="44px"
                android:layout_height="41px"
                android:src="@drawable/white_back"/>
        </com.zhy.autolayout.AutoLinearLayout>


        <TextView
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="end"
            android:textColor="@color/white"
            android:id="@+id/text_event_name"
            android:textSize="36px"
            android:layout_alignTop="@+id/manager_back"
            android:layout_centerHorizontal="true"
            android:gravity="center"/>

    </com.zhy.autolayout.AutoRelativeLayout>



    <com.zhy.autolayout.AutoLinearLayout
        android:id="@+id/ll_manager1"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:background="#33ffffff">
        <com.zhy.autolayout.AutoLinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">
            <TextView
                android:id="@+id/manager_participants"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="42px"
                android:textColor="@color/ff5c"
                android:gravity="center"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/participants"
                android:textColor="@color/white"
                android:textSize="24px"/>
        </com.zhy.autolayout.AutoLinearLayout>

        <com.zhy.autolayout.AutoLinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">
            <TextView
                android:id="@+id/manager_income"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="42px"
                android:gravity="center"
                android:textColor="@color/ff5c"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/income"
                android:textColor="@color/white"
                android:textSize="24px"/>
        </com.zhy.autolayout.AutoLinearLayout>

        <com.zhy.autolayout.AutoLinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">
            <TextView
                android:id="@+id/manager_checkin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="42px"
                android:gravity="center"
                android:textColor="@color/ff5c"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/checkin"
                android:textColor="@color/white"
                android:textSize="24px"/>
        </com.zhy.autolayout.AutoLinearLayout>
    </com.zhy.autolayout.AutoLinearLayout>

</com.zhy.autolayout.AutoRelativeLayout>

<com.zhy.autolayout.AutoFrameLayout
    android:id="@+id/manager_framelayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="10dp"
    android:visibility="gone">
    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/manager_progress"
        android:layout_gravity="center"
        android:visibility="gone"/>
</com.zhy.autolayout.AutoFrameLayout>

<com.zhy.autolayout.AutoRelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10px">
    <ImageView
        android:layout_width="42px"
        android:layout_height="42px"
        android:src="@drawable/ticket"
        android:id="@+id/img_title_ticket"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="15px"
        android:layout_marginStart="15px" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="32px"
        android:text="门票"
        android:textColor="@color/black"
        android:id="@+id/title_ticket"
        android:layout_alignBottom="@+id/img_title_ticket"
        android:layout_toEndOf="@+id/img_title_ticket"
        android:layout_marginStart="10dp"
        android:gravity="center"
        android:layout_alignTop="@+id/img_title_ticket" />
    <View
        android:layout_width="match_parent"
        android:layout_height="4dp"
        android:background="@drawable/bg_shadow"
        android:layout_below="@+id/img_title_ticket"
        android:layout_alignParentStart="true"
        android:layout_marginTop="10dp"/>
</com.zhy.autolayout.AutoRelativeLayout>

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/manager_swiperefresh"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ListView
        android:id="@+id/lv_ticket"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cacheColorHint="@android:color/transparent"
        android:listSelector="@android:color/transparent"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp">
    </ListView>
</android.support.v4.widget.SwipeRefreshLayout>

</com.zhy.autolayout.AutoLinearLayout>

fragment调用:
@OverRide
public View onCreateView(LayoutInflater inflater, @nullable ViewGroup container, @nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.ticket, container, false);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        StatusBarUtil.setTranslucentForImageView(getActivity(),0,(ImageView)view.findViewById(R.id.banner));
    }

    return view;
}

我在build.gradle开启vectorDrawables.useSupportLibrary = true后报空指针

defaultConfig {
vectorDrawables.useSupportLibrary = true
}
报错地方:
private static void setRootView(Activity activity) {
ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
rootView.setFitsSystemWindows(true);
rootView.setClipToPadding(true);
}
这里拿不到根布局了

有DrawerLayout的状态栏没有效果

使用StatusBarUtil.setColorNoTranslucentForDrawerLayout()和StatusBarUtil.setColorForDrawerLayout()都没有效果,状态栏一直是默认的颜色,一直是colorPrimary设置的颜色

4.4系统在切换fragment时改变状态栏有问题

首页用的图片,其他三个fragment用的颜色,发现切换到其他界面后在切回首页,图片有部分会被不见掉。debug看了一下,第一次进来,调用clearPreviousSetting方法时,不会调用以下代码

if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
            decorView.removeViewAt(count - 1);
            ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
            rootView.setPadding(0, -getStatusBarHeight(activity), 0, 0);
        }

所以显示正常。
切换到其他界面在切回首页时,会调用上面的代码,导致paddingTop是负数,图片上移,所以看起来上面有部分不见了。
修改为rootView.setPadding(0, 0, 0, 0);后发现可以用了

小米手机 4.4 版本 StatusBarUtil.setColor 方法和 StatusBarUtil.setTransparentForImageViewInFragment 方法切换调用会停止运行。

如题,当我这个View快速向下滑动会出现异常 如果慢慢往下滑则不会 请猴子大神帮忙看看

scrollableLayout.setOnScrollListener(new ScrollableLayout.OnScrollListener() {
            @Override
            public void onScroll(int currentY, int maxY) {
                if (currentY > mHeight / 1.5) {
                    if (isTransparent) {
                        isTransparent = false;
                        StatusBarUtil.setColor(activity, ContextCompat.getColor(activity, R.color.common_red));
                        rlTitleBar.setBackgroundColor(ContextCompat.getColor(activity, R.color.common_red));
                    }
                } else {
                    if (!isTransparent) {
                        isTransparent = true;
                        StatusBarUtil.setTransparentForImageViewInFragment(activity, null);
                        rlTitleBar.setBackgroundColor(ContextCompat.getColor(activity, R.color.transparent));
                    }
                }
            }
        });

异常信息:

          java.lang.NullPointerException
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3072)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
                                                                at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
                                                                at android.view.ViewRootImpl.draw(ViewRootImpl.java:2427)
                                                                at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2299)
                                                                at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1929)
                                                                at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1046)
                                                                at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5655)
                                                                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
                                                                at android.view.Choreographer.doCallbacks(Choreographer.java:574)
                                                                at android.view.Choreographer.doFrame(Choreographer.java:544)
                                                                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
                                                                at android.os.Handler.handleCallback(Handler.java:733)
                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                at android.os.Looper.loop(Looper.java:136)
                                                                at android.app.ActivityThread.main(ActivityThread.java:5052)
                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                at java.lang.reflect.Method.invoke(Method.java:515)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
                                                                at dalvik.system.NativeStart.main(Native Method)

toolbar被覆盖了statusbar的位置

出现的问题:toolbar被覆盖了statusbar的位置,米3, Sys:6.1

xml:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dl_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#ccffee" />


        <FrameLayout
            android:id="@+id/fl_main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />


    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_main_menu_parent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start">

        <FrameLayout
            android:id="@+id/fl_main_menu"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>


</android.support.v4.widget.DrawerLayout>

java:
@OverRide
public void setStatusBar() {
StatusBarUtils.setTranslucentForDrawerLayout(this, dl_main, 0);
}

DrawerLayout中toolbar设置app:layout_scrollFlags="scroll|enterAlways"问题

当向上滑动时,本该被状态栏遮住的toolbar却显示在了状态栏上面,

        StatusBarUtil.setColorForDrawerLayout(this, drawer,
                ContextCompat.getColor(this,R.color.colorPrimary), 0);

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:contentInsetStart="0dp"
            app:layout_scrollFlags="scroll|enterAlways"
            >

晕,为什么我就是没效果??

StatusBarUtil.setTransparent(this);
StatusBarUtil.setTranslucent(this, StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
状态栏都是白茫茫的一条,style文件设置了,找不到原因

询问项目内的一个第三方库

大圣,在Fragmen内使用StatusBarUtil案例中,底部菜单栏所使用的是一个第三方库(bottom-navigation-bar),有源码地址吗?请告知

Alpha的问题

我小米和各版本模拟器上将alpha设置为0为什么得到的却是一个浅灰色的状态栏背景

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

<?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" /> <include layout="@layout/include_toolbar"/> </FrameLayout>
这是我的查看大图界面布局,viewpager里是包含photoview的fragment,我用StatusBarUtil.setTransparent(this);

StatusBarUtil.setColor(this, Color.BLUE)位移不对

StatusBarUtil.setColor(this, Color.BLUE);
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> @color/colorPrimary @color/colorPrimaryDark @color/colorAccent false false true @android:color/transparent true true </style>
<style name="Theme.AppCompat.Translucent" parent="AppTheme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>

`_

_`

Fragment切换statusbar

现在有四个Fragment来回之间的切换,首页的顶部是图片需要扩展到状态栏,就是沉浸式状态栏,但是其他的都是colorPrimary的颜色状态栏,,应该如何实现呢

Cannot compile

I cannot compile my app because

Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:14:9
    is also present at com.jaeger.statusbaruitl:library:1.0.0:12:9 value=(true)
    Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:12:5 to override

Maybe the issue is in the AndroidManifest.xml of the library

魅族Note3状态栏切换颜色随机换

魅族Note3机型
StatusBarUtil.setColor(MainActivity.this, Color.BLACK);
设置后颜色时灵时不灵,有时候黑色,有时候透明,
开始进入是可以,A进入B页面,B页面顶部用的Imageview
StatusBarUtil.setTranslucentForImageView(this, 0, mRlayoutNoteDetailTop);
B返回到A页面,然后A的状态栏变为透明色,
我在A页面的OnResume也设置了
StatusBarUtil.setColor(MainActivity.this, Color.BLACK);
还是不可以!!

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.