问题描述
我这个下面的资源库在这里工作:
I am working with this following Repository here:
整体而言,这是很好的资源库,但缺乏复杂布局方案。我要实现的是这样的:
Overall it is good repository but lacks complex layout schemes. I want to achieve something like this:
当DO SOMETHING按钮包含在 AppBarLayout
和嵌套在 CollapsingToolbarLayout
,它崩溃,你向上滑动。那是我最初的想法,但它似乎不给我,我要找的行为。
Where the "DO SOMETHING" button is contained inside AppBarLayout
and nested inside CollapsingToolbarLayout
, and it collapses as you scroll up. That is my original thought, but it doesn't seem to give me the behavior I am looking for.
这是我的XML布局是这样的:
This is what my XML Layout looks like:
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<ImageView />
<android.support.v7.widget.Toolbar />
</android.support.design.widget.CollapsingToolbarLayout>
<Button/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView>
<LinearLayout>
<android.support.v7.widget.CardView>
<LinearLayout>
<TextView/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton />
如何去实现这样的事情?
How would I go about accomplishing something like that?
推荐答案
我可以通过实施来解决这个问题,以下内容:
I was able to solve this issue by implementing the following:
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<!-- BUTTON INSERTED HERE -->
<Button />
<android.support.design.widget.TabLayout />
<android.support.v4.view.ViewPager />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
这篇关于AppBarLayout和CollapsingToolbarLayout不能够遏制按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!