AppBarLayout 和 CollapsingToolbarLayout 不能包含 Button?
AppBarLayout and CollapsingToolbarLayout not able to contain Button?
我正在使用以下存储库:
CheeseSquare Repo via Chris Banes
总的来说,它是一个很好的存储库,但缺乏复杂的布局方案。我想实现这样的目标:
其中 "DO SOMETHING" 按钮包含在 AppBarLayout
内并嵌套在 CollapsingToolbarLayout
内,向上滚动时它会折叠。这是我最初的想法,但它似乎并没有给我我正在寻找的行为。
这是我的 XML 布局的样子:
<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 />
我将如何着手完成这样的事情?
我通过执行以下操作解决了这个问题:
<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>
我正在使用以下存储库:
CheeseSquare Repo via Chris Banes
总的来说,它是一个很好的存储库,但缺乏复杂的布局方案。我想实现这样的目标:
其中 "DO SOMETHING" 按钮包含在 AppBarLayout
内并嵌套在 CollapsingToolbarLayout
内,向上滚动时它会折叠。这是我最初的想法,但它似乎并没有给我我正在寻找的行为。
这是我的 XML 布局的样子:
<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 />
我将如何着手完成这样的事情?
我通过执行以下操作解决了这个问题:
<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>