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

CoordinatorLayout为根布局,Toolbar偏上 #45

Closed zhufengweihai closed 7 years ago

zhufengweihai commented 7 years ago

如题,怎么解决?

laobie commented 7 years ago

@zhufengweihai 截图看看,贴一下代码

zhufengweihai commented 7 years ago

image

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                 xmlns:app="http://schemas.android.com/apk/res-auto"
                                                 xmlns:tools="http://schemas.android.com/tools"
                                                 android:id="@+id/rootView"
                                                 android:layout_width="match_parent"
                                                 android:layout_height="match_parent"
                                                 android:background="@drawable/background_for_default"
                                                 tools:context=".WeatherForecastActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/weather_app_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/transparent"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <ImageView
                android:id="@+id/addCityButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingRight="10dp"
                android:src="@mipmap/ic_add_city"/>

            <TextView
                android:id="@+id/cityView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="青岛"
                android:textColor="@android:color/white"
                android:textSize="20sp"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="end"
                android:paddingRight="15dp"
                android:src="@mipmap/ic_share"/>
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_weather_forecast"/>

</android.support.design.widget.CoordinatorLayout>
laobie commented 7 years ago

@zhufengweihai 你调用的哪个方法

zhufengweihai commented 7 years ago

@laobie StatusBarUtil.setTranslucentForCoordinatorLayout(this, 0);

zhufengweihai commented 7 years ago

貌似改成<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:popupTheme="@style/AppTheme.PopupOverlay">

能正确显示O(∩_∩)O~

laobie commented 7 years ago

@zhufengweihai

啊 我还没测试出来,如果可以的话,我明天在 readme 中加一下

zhufengweihai commented 7 years ago

@laobie 我试了一下,不再偏上了,你可以自测一下试试。O(∩_∩)O~

laobie commented 7 years ago

@zhufengweihai 好哒,感谢反馈

zhufengweihai commented 7 years ago

客气应该的,还得感谢你这么好用的库呢。试了很多方法才找到你这个库

laobie commented 7 years ago

@zhufengweihai 写了这么多 Bug 不好意思啊 😂

zhufengweihai commented 7 years ago

这一块确实比较复杂,有点bug很正常。O(∩_∩)O~