我正在尝试向我的片段广告一个晶圆厂,但它隐藏在导航栏后面.问题是出现的布局对他的活动感兴趣,滚动行为设置为我附加片段的框架布局.如何将此行为添加到片段中的回收器视图,而无需将工具栏添加到片段.这是因为我有很多片段而且只有一个活动
Navigation_drawer_layout
<?xml version="1.0" enCoding="utf-8"?><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:ID="@+ID/drawer_layout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:fitsSystemwindows="true" tools:openDrawer="close"> <androID.support.design.Widget.CoordinatorLayout androID:ID="@+ID/coordinatorLayout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical"> <androID.support.design.Widget.AppbarLayout androID:ID="@+ID/appbarLayout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:fitsSystemwindows="true"> <include androID:ID="@+ID/toolbar" layout="@layout/toolbar" /> </androID.support.design.Widget.AppbarLayout> <FrameLayout androID:ID="@+ID/content_frame" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" /> </androID.support.design.Widget.CoordinatorLayout> <androID.support.design.Widget.NavigationVIEw androID:ID="@+ID/nav_vIEw" androID:layout_wIDth="wrap_content" androID:layout_height="match_parent" androID:layout_gravity="start" androID:theme="@style/NavigationDrawerStyle" app:itemIconTint="@color/PrimaryPurple" app:menu="@menu/activity_dasboard_drawer" /></androID.support.v4.Widget.DrawerLayout>
fragment_layout
<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/coordinatorLayout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical"> <relativeLayout androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"> <androID.support.v7.Widget.RecyclerVIEw androID:ID="@+ID/food_queue_recycle_List" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:background="@color/Title_white" /> <androID.support.v7.Widget.CardVIEw xmlns:card_vIEw="http://schemas.androID.com/apk/res-auto" androID:ID="@+ID/card_vIEw_no_items" androID:layout_wIDth="350dp" androID:layout_height="200dp" androID:layout_centerInParent="true" androID:visibility="gone" card_vIEw:cardCornerRadius="2dp" card_vIEw:cardElevation="4dp"> <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:gravity="center"> <ImageVIEw androID:ID="@+ID/errorImageVIEw" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_alignParenttop="true" androID:layout_centerHorizontal="true" androID:contentDescription="@string/empty_favourite_List" androID:src="@drawable/food_icon_empty" /> <TextVIEw androID:ID="@+ID/errorTextVIEw" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_below="@+ID/errorImageVIEw" androID:layout_margintop="@dimen/large_text_size" androID:gravity="center" androID:text="@string/empty_favourite_List" androID:textAllCaps="true" androID:textcolor="@color/SecondaryBlack" androID:textSize="@dimen/medium_text_size" androID:textStyle="bold" /> </relativeLayout> </androID.support.v7.Widget.CardVIEw> </relativeLayout> <androID.support.design.Widget.floatingActionbutton androID:ID="@+ID/action_edit" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="bottom|end" androID:layout_margin="@dimen/fab_margin" androID:src="@drawable/ic_mode_edit_48px" app:backgroundTint="@color/PrimaryPurple" app:layout_anchor="@ID/food_queue_recycle_List" app:layout_anchorGravity="bottom|right|end" app:layout_behavior="helpers.FABCoordinatorBehavior" /></androID.support.design.Widget.CoordinatorLayout>
解决方法:
DanIEl Nugent是对的.你可以这样做:
只需将floatingActionbutton放在该mainlayout上就像这样:
<?xml version="1.0" enCoding="utf-8"?><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:ID="@+ID/drawer_layout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:fitsSystemwindows="true" tools:openDrawer="close"> <androID.support.design.Widget.CoordinatorLayout androID:ID="@+ID/coordinatorLayout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical"> <FrameLayout androID:ID="@+ID/content_frame" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" /> <androID.support.design.Widget.AppbarLayout androID:ID="@+ID/appbarLayout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:fitsSystemwindows="true"> <include androID:ID="@+ID/toolbar" layout="@layout/toolbar" /> </androID.support.design.Widget.AppbarLayout> <androID.support.design.Widget.floatingActionbutton androID:ID="@+ID/action_edit" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="bottom|end" androID:layout_margin="@dimen/fab_margin" androID:src="@drawable/ic_mode_edit_48px" app:backgroundTint="@color/PrimaryPurple" app:layout_anchor="@ID/food_queue_recycle_List" app:layout_anchorGravity="bottom|right|end" app:layout_behavior="helpers.FABCoordinatorBehavior" /> </androID.support.design.Widget.CoordinatorLayout> <androID.support.design.Widget.NavigationVIEw androID:ID="@+ID/nav_vIEw" androID:layout_wIDth="wrap_content" androID:layout_height="match_parent" androID:layout_gravity="start" androID:theme="@style/NavigationDrawerStyle" app:itemIconTint="@color/PrimaryPurple" app:menu="@menu/activity_dasboard_drawer" /></androID.support.v4.Widget.DrawerLayout>
然后在Fragment中使用RecyclerVIEw:
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:card_vIEw="http://schemas.androID.com/apk/res-auto" androID:ID="@+ID/coordinatorLayout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"> <androID.support.v7.Widget.RecyclerVIEw androID:ID="@+ID/food_queue_recycle_List" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:background="@color/Title_white" /> <!-- not sure about this, but, it shouldn't be here --> <!--<androID.support.v7.Widget.CardVIEw androID:ID="@+ID/card_vIEw_no_items" androID:layout_wIDth="350dp" androID:layout_height="200dp" androID:layout_centerInParent="true" androID:visibility="gone" card_vIEw:cardCornerRadius="2dp" card_vIEw:cardElevation="4dp"> <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:gravity="center"> <ImageVIEw androID:ID="@+ID/errorImageVIEw" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_alignParenttop="true" androID:layout_centerHorizontal="true" androID:contentDescription="@string/empty_favourite_List" androID:src="@drawable/food_icon_empty" /> <TextVIEw androID:ID="@+ID/errorTextVIEw" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_below="@+ID/errorImageVIEw" androID:layout_margintop="@dimen/large_text_size" androID:gravity="center" androID:text="@string/empty_favourite_List" androID:textAllCaps="true" androID:textcolor="@color/SecondaryBlack" androID:textSize="@dimen/medium_text_size" androID:textStyle="bold" /> </relativeLayout> </androID.support.v7.Widget.CardVIEw>--></relativeLayout>
我不确定那个CardVIEw,因为你将RecyclerVIEw设置为match_parent:
<androID.support.v7.Widget.RecyclerVIEw androID:ID="@+ID/food_queue_recycle_List" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:background="@color/Title_white" />
所以,那些卡不应该在那里.(除非你需要将它显示为错误卡)通过将setVisibility设置为GONE,然后处理是否有错误,通过以下方式显示:setVisibility == VIEw.VISIBLE.
总结以上是内存溢出为你收集整理的android – 隐藏在导航抽屉后面的浮动 *** 作按钮全部内容,希望文章能够帮你解决android – 隐藏在导航抽屉后面的浮动 *** 作按钮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)