
我想制作collasPing工具栏,其中是我的自定义Layout.在下图中显示了使用新发布的design.support lib.在img.1上,元素(ImageVIEw)正在消失.在我的项目中,我想要消除布局.
因为内部布局将是VIEwPager,它不能像图像那样调整大小,它应该溶解在工具栏背景中 – 应该变得透明.
另外我想通过移动ToolbarFooter打开/隐藏ToolbarLayout – 带移动 – 亮蓝色布局.因此,展开/折叠与img.1不同.相反,它应该像状态栏一样,通过单击ToolbarFooter来上下移动.
img.2这个想法是我读了很多(collapsing with button,layout inside),但我发现了任何线索或实现.我不知道如何处理这个话题.
我想我的VIEwPager和relativeLayout(或其他)应该在工具栏之外.他们应该像这样取一个工具栏视图:
<androID.support.v4.Widget.DrawerLayoutxmlns: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"><relativeLayout 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:clipChildren="false"> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/app_bar" androID:layout_wIDth="match_parent" androID:layout_height="@dimen/app_bar_max_height" androID:minHeight="?attr/actionbarSize" app:popuptheme="@style/themeOverlay.AppCompat.light" app:theme="@style/Appbartheme"> <button androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:layout_alignParenttop="true" androID:layout_gravity="left|top" androID:gravity="center_vertical|left" androID:text="ToolbarTitle" androID:background="?androID:attr/selectableItemBackground" androID:textAllCaps="false"/> </androID.support.v7.Widget.Toolbar> <net.androID.app.vIEws.VIEwPagerToolbar androID:ID="@+ID/calendar_vIEwpager" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_alignParenttop="true" androID:layout_margintop="?attr/actionbarSize"/> <relativeLayout androID:ID="@+ID/toolbar_footer" androID:layout_wIDth="match_parent" androID:layout_height="@dimen/app_bar_height" androID:layout_alignParenttop="false" androID:layout_alignBottom="@+ID/app_bar"> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_centerHorizontal="true" androID:layout_marginBottom="8dp" androID:text="@string/belt_to_move"/> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentBottom="true" androID:layout_centerHorizontal="true" androID:text="@string/belt_to_move"/> </relativeLayout> <androID.support.v4.Widget.DrawerLayout androID:ID="@+ID/drawer_layout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_below="@+ID/app_bar"> <androID.support.v4.vIEw.VIEwPager androID:ID="@+ID/vp_container" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"/> </androID.support.v4.Widget.DrawerLayout></relativeLayout><androID.support.design.Widget.NavigationVIEw androID:ID="@+ID/navVIEw" androID:layout_wIDth="wrap_content" androID:layout_height="match_parent" androID:layout_gravity="start"/>现在任何人都可以告诉我应该使用哪个组件?
支持库提供CoordinateLayout,CollapsedToolbar,Appbar.
通过标准方法可以使用relativeLayout或FrameLayout重叠视图.那么大家你推荐我什么,我应该从哪个方面吃这个蛋糕?
更新:
最后我找到了解决方案.它不是CollapsingToolbar而是VIEwDragHelper.
我遵循的解决方案:Blog,GitHub project,YouTube explanation,
解决方法:
您需要在工具栏上方附加vIEwPager.
ImageVIEw示例:
<androID.support.design.Widget.AppbarLayout androID:ID="@+ID/appbar" androID:layout_wIDth="match_parent" androID:layout_height="240dp" androID:fitsSystemwindows="true" androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar" app:elevation="2dp"><androID.support.design.Widget.CollapsingToolbarLayout androID:ID="@+ID/collapsing_toolbar" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:fitsSystemwindows="true" app:contentScrim="?attr/colorPrimary" app:elevation="2dp" app:collapsedTitleTextAppearance="?attr/autoCompleteTextVIEwStyle" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" > // put here your content <androID.support.v7.Widget.Toolbar androID:ID="@+ID/anim_toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" app:layout_collapseMode="pin" app:elevation="2dp" app:popuptheme="@style/themeOverlay.AppCompat.light"/> </relativeLayout> </androID.support.design.Widget.CollapsingToolbarLayout></androID.support.design.Widget.AppbarLayout> 总结 以上是内存溢出为你收集整理的android – 折叠工具栏.如何调整自定义布局而不是默认的ImageView全部内容,希望文章能够帮你解决android – 折叠工具栏.如何调整自定义布局而不是默认的ImageView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)