我遇到了新的支持库26.1.0的问题,同样的废话正在进行27.0.0,但25.x.x似乎一切正常。
它是来自Android工作室示例的示例应用程序,滚动活动。
HORRIBLE !!
我制作了一个视频,只是做了一次投掷行为,快照滚动标记看起来完全坏了,我也不知道状态栏是怎么回事,好像有一个叠加层被投掷的力量所吸引(facepalm)。
严重的是谷歌,你在每次更新时都会破坏支持库。一旦支持库发生变化,我真的厌倦了更新并关注整个应用程序。它是如此荒谬,你是开发人员应该信任和依赖的人,但似乎不再是这种情况了,因为你总是浪费开发人员的时间,总是用GUI来破坏它。
这需要添加到v21下的主题:
<item name="android:statusBarColor">@android:color/transparent</item>
Xml视图
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<ImageView
android:id="@+id/ivImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/img1"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="@string/large_text" />
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@android:drawable/ic_dialog_email" />
答案 0 :(得分:0)
我遇到了同样的问题,并设法通过从layout_scrollFlags中删除 snap 来至少缓解这种奇怪的行为:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
然而,你可能会猜到你会失去对齐。