新的Android设计库与AppBarLayout和工具栏的bug [英] New Android Design Library bug with AppBarLayout and Toolbar
问题描述
我现在用的是最新的Android设计库基于这个例子 chrisbanes / cheesesquare 在github上和<一href="http://android-developers.blogspot.com/2015/05/android-design-support-library.html">here
我已经运行的例子,我有问题的工具栏里面CheeseDetailActivity。示,因为它应该的工具栏未启用。看看下面的图片:
在第一个图像,你可以看到工具栏无法正确地显示。
在第二个图像,你可以看到工具栏显示正确,但在通知栏是白色的。这是因为我从actiivty_detail.xml Android的删除:fitsSystemWindows =真正的
从 android.support.design.widget.CoordinatorLayout
我觉得 fitsSystemWindows
应该是真的,问题与 android.support.design.widget.AppBarLayout
但我没有任何想法如何,我可以解决这个问题。我试着用 marginTop
具有相同的高度 notificationBar
,但没有奏效。
任何建议是AP preciated:)
这是一部分的 activity_detail.xml
:
&LT; android.support.design.widget.CoordinatorLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / main_content
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真正的&GT;
&LT; android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / appbar
机器人:layout_width =match_parent
机器人:layout_height =@扪/ detail_backdrop_height
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
机器人:fitsSystemWindows =真正的&GT;
&LT; android.support.design.widget.CollapsingToolbarLayout
机器人:ID =@ + ID / collapsing_toolbar
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用程序:layout_scrollFlags =滚动| exitUntilCollapsed
机器人:fitsSystemWindows =真
应用程序:contentScrim =?ATTR / colorPrimary
应用程序:expandedTitleMarginStart =48dp
应用程序:expandedTitleMarginEnd =64dp&GT;
&LT; ImageView的
机器人:ID =@ + ID /背景
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:scaleType =centerCrop
机器人:fitsSystemWindows =真
应用程序:layout_collapseMode =视差/&GT;
&LT; android.support.v7.widget.Toolbar
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
应用程序:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
应用程序:layout_collapseMode =针/&GT;
&LT; /android.support.design.widget.CollapsingToolbarLayout>
&LT; /android.support.design.widget.AppBarLayout>
更改您的设计库的与新版本的 build.gradle 文件中的应用文件夹,如:
编译com.android.support:design:22.2.1
由于更新了 + AndroidDevelopers
我得到了像输出:
它会帮助你。
谢谢:)
I am using the new Android Design Library based on this example chrisbanes/cheesesquare in github and here
I have run the example and I am having problems with Toolbar inside CheeseDetailActivity. The toolbar isnt shown as it should. Have a look at the images below:
At first image you can see the toolbar isn't shown correctly.
At the second image you can see that the toolbar is shown correctly but the notification bar is white. This happens because I removed from actiivty_detail.xml android:fitsSystemWindows="true"
from android.support.design.widget.CoordinatorLayout
I think that fitsSystemWindows
should be true and the problem is related with android.support.design.widget.AppBarLayout
but I don't have any idea how I can fix this problem. I tried with marginTop
with the same height as notificationBar
but it didn't work.
Any suggestion is appreciated :)
This is a part of the activity_detail.xml
:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Change your Design Library with New Version build.gradle file in app folder like:
compile 'com.android.support:design:22.2.1'
As Updated in +AndroidDevelopers
I got output like:
It will helps you.
Thanks :)
这篇关于新的Android设计库与AppBarLayout和工具栏的bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!