
我使用NavigationDrawer并在具有不同片段的项目之间切换,同时替换FrameLayout,并将工具栏留在应用程序中.
其中一个片段有一个标签布局.
当我显示该片段时,它显示在工具栏下方,工具栏阴影与其重叠.
我希望它与工具栏处于同一级别,并且看起来和行为类似于它在同一个AppbarLayout中.
此外,我想在展开工具栏时使标签透明.
如何重新组织布局以使其有效?
这是我的Xml:
主Xml:
<androID.support.v4.Widget.DrawerLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_gravity="right" androID:clickable="true" androID:layoutDirection="rtl" androID:fitsSystemwindows="true" androID:ID="@+ID/drawer_layout"><androID.support.design.Widget.CoordinatorLayout androID:ID="@+ID/mainCoordinatorLayout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layoutDirection="rtl" androID:background="#EEEEEE" androID:clickable="true"> <androID.support.design.Widget.AppbarLayout androID:layout_height="wrap_content" androID:layout_wIDth="match_parent" androID:ID="@+ID/toolbar_layout"> <androID.support.design.Widget.CollapsingToolbarLayout androID:ID="@+ID/collapsing_toolbar" androID:layout_wIDth="match_parent" androID:layout_height="250dp" app:collapsedTitleGravity="right" androID:fitsSystemwindows="true" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:contentScrim="?attr/colorPrimary" app:collapsedTitleTextAppearance="@style/CollapsedTitleTextAppearance" app:expandedTitleTextAppearance="@style/ExpandedTitleTextAppearance" app:expandedTitlemarginEnd="64dp" app:expandedTitlemarginStart="48dp"> <ImageVIEw androID:ID="@+ID/headerImage" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:fitsSystemwindows="true" androID:scaleType="centerCrop" app:layout_collapseMode="parallax" androID:src="@drawable/soldIEr" /> <VIEw androID:layout_wIDth="match_parent" androID:layout_height="88dp" androID:background="@drawable/scrim_top" app:layout_collapseMode="pin" /> <VIEw androID:layout_wIDth="match_parent" androID:layout_height="88dp" androID:layout_gravity="bottom" androID:layout_alignBottom="@+ID/headerImage" androID:background="@drawable/scrim_bottom" /> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:theme="@style/WhiteTitle" app:layout_scrollFlags="scroll|enteralways" app:TitleTextcolor="@color/White" androID:fitsSystemwindows="true" androID:layout_gravity="right" androID:layoutDirection="rtl" app:layout_collapseMode="pin" /> </androID.support.design.Widget.CollapsingToolbarLayout> </androID.support.design.Widget.AppbarLayout> <FrameLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:ID="@+ID/content_frame" androID:animateLayoutChanges="true" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"> <androID.support.v4.Widget.nestedScrollVIEw androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" androID:fillVIEwport="true" /> </FrameLayout> <androID.support.design.Widget.floatingAction@R_403_5554@ androID:ID="@+ID/mainFab" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentBottom="true" androID:layout_alignParentleft="true" androID:layout_gravity="bottom|end" androID:layout_marginleft="16dp" androID:layout_marginBottom="16dp" androID:layout_margintop="5dp" androID:elevation="8dp" app:pressedTranslationZ="12dp" app:backgroundTint="?androID:colorAccent" androID:src="@drawable/ic_perm_phone_msg_white_24px" /> <linearLayout androID:ID="@+ID/miniFabFrame" androID:orIEntation="vertical" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:visibility="invisible" androID:layout_alignParentleft="true" androID:layout_gravity="bottom|end" androID:layout_marginleft="20dp" androID:layout_marginBottom="80dp" androID:padding="0dp"> <androID.support.design.Widget.floatingAction@R_403_5554@ androID:ID="@+ID/messageFab" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentBottom="true" androID:layout_alignParentleft="true" androID:elevation="8dp" androID:layout_margintop="5dp" androID:layout_marginRight="0dp" androID:layout_marginBottom="5dp" androID:layout_marginleft="5dp" app:pressedTranslationZ="12dp" app:backgroundTint="?androID:colorPrimary" app:fabSize="mini" androID:src="@drawable/ic_textSMS_white_24px" /> <androID.support.design.Widget.floatingAction@R_403_5554@ androID:ID="@+ID/callFab" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentBottom="true" androID:layout_alignParentleft="true" androID:layout_margintop="5dp" androID:layout_marginRight="0dp" androID:layout_marginBottom="5dp" androID:layout_marginleft="5dp" androID:elevation="8dp" app:pressedTranslationZ="12dp" app:backgroundTint="?androID:colorPrimary" app:fabSize="mini" androID:src="@drawable/ic_call_white_24px" /> </linearLayout></androID.support.design.Widget.CoordinatorLayout><androID.support.design.Widget.NavigationVIEw androID:layout_wIDth="wrap_content" androID:layout_height="match_parent" androID:layout_gravity="right" androID:ID="@+ID/nav_vIEw" androID:layoutDirection="rtl" app:headerLayout="@layout/header" app:menu="@menu/nav_menu" />
带标签布局的片段:
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:fitsSystemwindows="true" androID:ID="@+ID/halachot_layout" androID:layoutDirection="ltr" androID:animateLayoutChanges="true"> <androID.support.design.Widget.AppbarLayout androID:layout_height="wrap_content" androID:layout_wIDth="match_parent" androID:elevation="0dp" androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar"> <com.refractored.PagerSlIDingTabStrip androID:ID="@+ID/halachottabs" androID:layout_below="@ID/halachot_layout" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:background="@androID:color/transparent" androID:fitsSystemwindows="true" pstspaddingMIDdle="false" app:pstsShouldExpand="true" /> </androID.support.design.Widget.AppbarLayout> <androID.support.v4.vIEw.VIEwPager androID:ID="@+ID/halachotPager" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="1" /></linearLayout>
任何指导将不胜感激.
谢谢.
解决方法 你应该做这样的结构<?xml version="1.0" enCoding="utf-8"?><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.support.design.Widget.AppbarLayout androID:ID="@+ID/appbar" androID:layout_wIDth="match_parent" androID:layout_height="256dp" 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="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <androID.support.design.Widget.TabLayout androID:ID="@+ID/tabs" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:layout_gravity="bottom" app:tabMode="scrollable" app:tabContentStart="72dp" /> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:background="?attr/colorPrimary" app:popuptheme="@style/themeOverlay.AppCompat.light" app:layout_collapseMode="parallax" /> </androID.support.design.Widget.CollapsingToolbarLayout> </androID.support.design.Widget.AppbarLayout> <androID.support.v4.vIEw.VIEwPager androID:ID="@+ID/vIEwpager" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" /> <androID.support.design.Widget.floatingAction@R_403_5554@ androID:ID="@+ID/fab" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="end|bottom" androID:layout_margin="8dp" androID:src="@drawable/ic_done" app:layout_anchor="@ID/tabs" app:layout_anchorGravity="center|left|start" app:fabSize="mini" app:layout_behavior="com.support.androID.designlibdemo.ScrollAwareFABBehavior" app:borderWIDth="0dp" /></androID.support.design.Widget.CoordinatorLayout>
取自here
另见this答案,那里解释得很好.
如果您想进一步解释,请阅读这些博客
http://blog.grafixartist.com/parallax-scrolling-tabs-design-support-library
http://blog.nkdroidsolutions.com/collapsing-toolbar-with-tabs-android-example
https://lab.getbase.com/nested-scrolling-with-coordinatorlayout-on-android/
总结以上是内存溢出为你收集整理的片段中的Android标签与折叠工具栏全部内容,希望文章能够帮你解决片段中的Android标签与折叠工具栏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)