android– 右下角的浮动动作按钮

android– 右下角的浮动动作按钮,第1张

概述我正在使用这个xml,它包含一个ListView和一个浮动动作按钮.我希望FAB始终位于右下角(但不要太靠近屏幕的边框),但它只适合列表的最后一项(所以当列表中有一个项目时,它就在右上角)<?xmlversion="1.0"encoding="utf-8"?><android.support.design.widget.CoordinatorLayoutxmln

我正在使用这个xml,它包含一个ListVIEw和一个浮动动作按钮.我希望FAB始终位于右下角(但不要太靠近屏幕的边框),但它只适合列表的最后一项(所以当列表中有一个项目时,它就在右上角)

<?xml version="1.0" enCoding="utf-8"?><androID.support.design.Widget.CoordinatorLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    xmlns:app="http://schemas.androID.com/apk/res-auto"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    tools:context="com.reminder.other_activitIEs.AllSimpleRemindersActivity">    <com.baoyz.swipemenuListvIEw.SwipeMenuListVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:ID="@+ID/simpleRems"        androID:divIDerHeight="0dp"        androID:divIDer="@null"        androID:layout_alignParenttop="true"        androID:layout_centerHorizontal="true"        androID:layout_alignParentBottom="true" />    <relativeLayout        androID:ID="@+ID/test"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent">    </relativeLayout>    <androID.support.design.Widget.floatingActionbutton        androID:layout_margin="10dp"        androID:ID="@+ID/myFAB"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        app:backgroundTint="#FF0000"        app:borderWIDth="0dp"        app:elevation="8dp"        app:layout_anchor="@ID/test"        app:layout_anchorGravity="bottom|right|end" /></androID.support.design.Widget.CoordinatorLayout>

解决方法:

尝试将SwipeMenuListVIEw高度设置为match_parent并删除测试相对布局.

<?xml version="1.0" enCoding="utf-8"?><androID.support.design.Widget.CoordinatorLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    xmlns:app="http://schemas.androID.com/apk/res-auto"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    tools:context="com.reminder.other_activitIEs.AllSimpleRemindersActivity">    <com.baoyz.swipemenuListvIEw.SwipeMenuListVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="match_parent"        androID:ID="@+ID/simpleRems"        androID:divIDerHeight="0dp"        androID:divIDer="@null"        androID:layout_alignParenttop="true"        androID:layout_centerHorizontal="true"        androID:layout_alignParentBottom="true" />    <androID.support.design.Widget.floatingActionbutton        androID:layout_margin="10dp"        androID:ID="@+ID/myFAB"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        app:backgroundTint="#FF0000"        app:borderWIDth="0dp"        app:elevation="8dp"        androID:layout_gravity="bottom|right"        app:layout_anchor="@ID/simpleRems"        app:layout_anchorGravity="bottom|right|end" /></androID.support.design.Widget.CoordinatorLayout>
总结

以上是内存溢出为你收集整理的android – 右下角的浮动动作按钮全部内容,希望文章能够帮你解决android – 右下角的浮动动作按钮所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1108267.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存