Chr*_*ski 3 xml android material-design android-design-library android-collapsingtoolbarlayout
CollapsingToolbarLayout | 滚动和布局问题2
我一直在努力与Android Support Design Library成功实施的CoordinatorLayout引起Toolbar和TabLayout滚动时滚动拿出来看.这非常有效,所以我想我会尝试新的运气CollapsingToolbarLayout.
在单独的活动中,我一直在执行问题CollapsingToolbarLayout.正如他们所说,我很接近,但没有雪茄.
我想使用2个不同的片段
ImageView)我自己构建了这个布局的一个例子,但经过多次尝试后无法使它工作.最后,我发现了[在这里输入图像描述] [5]并修改它以达到我现在的目的
注意:我不知道这些是否是由1件事(多米诺骨牌效应)引起的,或者这些是否是个体的.另外,我查看了很多相关问题,但似乎没有任何问题.
Scrollable Content 显示在标题图像上方Scrollable Content 没有固定在底部 Header Image滚动Scrollable Content它会滚动Header Image看似随机的:
Just right 并遵循手指的速度(完美)Too fast并Header Image通过移动我的手指1行文本的高度来动画屏幕此外Scroll down,上述2种效果与第3种效果同时发生
Instant或Near instant"动画"显示Header Image全宽编辑:下面的问题在另一个问题中被问到!! 上面有一个简单的修复
在CollapsingToolbarLayout不允许我展开Toolbar看全 Header Image
Top切割,但底部是可见的.该Toolbar设置为Pin,但滚动,当它被隐藏
Header Image应该消失<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<ImageView/> <!-- Will be a fragment later -->
<android.support.v7.widget.Toolbar/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView>
<fragment/> <!-- Not a scrolling fragment layout -->
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="16dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|enterAlways">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/download"
android:scaleType="centerCrop" />
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/imageView1">
<fragment
android:id="@+id/detail"
android:name="<package>.<fragment_name>"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
1
2
3 
4
五
6 
你需要添加app:layout_behavior="@string/appbar_scrolling_view_behavior"到你的NestedScrollView- 这标志着应该位于AppBarLayout(因此,在下面CollapsingToolbarLayout)的类.