floating-action-button 相关问题

浮动操作按钮是提升操作的特例。它们通过浮动在UI上方的带圆圈的图标来区分,并具有与变形,发射及其转移锚点相关的特殊运动行为。

如何使用fab在中心进行bottomnavigationview并在滚动时隐藏整个视图

我正在开发一个带有bottomnavigationview的应用程序与fab在中心。我需要隐藏整个视图(bottomview + fab)当我滚动像swiggy app.I已附加我的布局图片和xml ...

回答 1 投票 0

浮动操作按钮丢失

浮动操作菜单上的代码正在运行,但不显示其他浮动操作按钮。我在地图下面有一张谷歌地图和一份回收者视图。看来地图覆盖了另一个......

回答 1 投票 0

如何使用NestedScrollView

在我的应用程序中,我想使用NestedScrollView到DrawerLayout。为此我写下面的代码。我想在布局底部显示FAB,但是在卡片下方显示我!我不想在卡片的下面显示,我......

回答 3 投票 1

Android Master / Detail - 让FAB在单窗格或多窗格上锚定到master

我希望在平板电脑上显示两个窗格时,浮动操作按钮(FAB)将锚定到主窗格,就像Gmail应用程序一样(请参见附图),但无法对此进行编码...

回答 1 投票 0

扩展类android.support.design.widget.CoordinatorLayout时出错

我想在我的应用程序上使用FloatingActionButton,我读到这个:https://guides.codepath.com/android/Floating-Action-Buttons#google-s-official-support-library但是当我运行Activity I时... 。

回答 13 投票 33

我如何自定义浮动按钮,如Android消息应用程序?

怎么做到这一点?如何获得底部的浮动按钮?这有什么好的可靠的图书馆吗?

回答 1 投票 -2

如何将浮动操作按钮对齐到中心

我有一个FloatingActionButton。我希望它是2个LinearLayouts的中间和这样的屏幕中心。目前我的设计是这样的,我希望它在屏幕的正中心。怎么样 ...

回答 4 投票 9

浮动操作按钮未显示 - viewpager

我在这里读了一些关于这个问题的帖子,但我无法显示FAB。我尝试了不同的方法,但我并不是真的发生了什么。

回答 2 投票 4

浮动动作按钮android更改图标

我按照android studio上的模板创建了一个导航抽屉应用程序。如您所知,它使用浮动操作按钮和其中的电子邮件图标创建初始活动。我只是想改变它......

回答 1 投票 0

Android如何将FloatingActionButton置于正确的位置?

我正在尝试将FloatingActionButton放在地图上。我想在地图的“botton | right”位置放两个按钮,但效果不好。这是我在设计上可以看到的,我想做...

回答 4 投票 0

FloatingActionButton onPressed不触发

希望这里简单一点。我有动画的浮动按钮。他们似乎没有触发我的onPressed代码,只是似乎什么都不做,虽然我得到了“ViewPostImeInputStage ...

回答 1 投票 0

如何检测我们的应用程序上是否有另一个应用程序浮动按钮?

我想知道是否有任何方法可以识别应用程序浮动按钮位于我的Android应用程序/游戏屏幕上?例如看到这张图片:有一些游戏黑客应用程序,当......

回答 1 投票 0

检测何时隐藏浮动操作按钮

我有一个滚动活动,我希望在隐藏浮动操作按钮时收到通知。为了做到这一点,我创建了MyFab,它扩展了FloatingActionButton和一个接口(使用...

回答 1 投票 0

Native base的FAB开始激活

我知道我的问题与这个问题有关 - React Native - Native Base FAB(浮动操作按钮):单击FAB会自动调用子按钮'onpress'但是只要它不...

回答 1 投票 0

如何使浮动操作按钮背景渐变?

FAB的代码: FAB代码: <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right|end" android:layout_margin="16dp" android:src="@drawable/add_chat" android:tint="@android:color/white" /> </android.support.design.widget.CoordinatorLayout> 渐变背景代码: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <gradient android:angle="90" android:endColor="#e4849f" android:startColor="#d96e30" /> </shape> android:backgroundTint="" 或 app:backgroundTint="" 都只使用颜色资源。有人能建议怎么做吗? 谢谢!! 步骤 1. 创建一个新的 drawable.xml 并向其中添加此代码 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <gradient android:type="linear" android:angle="0" android:startColor="#f6ee19" android:endColor="#115ede" /> </shape> </item> <item android:gravity="center" > <bitmap android:src="@drawable/your_icon" android:gravity="fill_horizontal" /> </item> </layer-list> Step 2.) 现在在您的dimens.xml中添加这行代码, <dimen name="design_fab_image_size" tools:override="true">56dp</dimen> 步骤 3.) 最后使用 *android:src="@drawable/drawable.xml"* 在 FAB 中设置这个 drawable.xml 附言- 确保 your_icon 是 PNG, JPEG. 接受的答案工作正常,但在添加以下行后,它会拉伸添加在 FAB 上的图标 <dimen name="design_fab_image_size" tools:override="true">56dp</dimen> 我正在分享截图: 上一个FAB按钮 在dimen.xml中添加design_fab_image_size并添加android:src="@drawable/gradient"后,图标被拉伸: 为了解决这个问题,我将 gradient.xml 替换为以下代码: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <gradient android:angle="90" android:startColor="#00FF00" android:endColor="#000000" /> <size android:width="56dp" android:height="56dp" /> </shape> </item> <item android:left="10dp" android:right="10dp"> <shape android:shape="line"> <stroke android:width="2dp" android:color="#ffffff" /> </shape> </item> <item android:left="10dp" android:right="10dp"> <rotate android:fromDegrees="90"> <shape android:shape="line"> <stroke android:width="2dp" android:color="#ffffff" /> </shape> </rotate> </item> 输出: 我尝试了很多不同的答案,但都有它们的缺点或不适用于material FAB。 当我意识到这不是不是它的意思时,我只是用ImageView替换了它。这很好用,看起来一模一样。 <ImageButton android:id="@+id/floatingActionButton" android:layout_width="56dp" android:layout_height="56dp" android:background="@drawable/fab_gradient" android:elevation="6dp" ... /> fab_gradient.xml: <ripple android:color="?attr/colorControlHighlight" xmlns:android="http://schemas.android.com/apk/res/android"> <item> <layer-list> <item> <shape android:shape="oval"> <gradient android:type="linear" android:angle="90" android:startColor="@color/startColor" android:endColor="@color/endColor" /> </shape> </item> <item android:drawable="@drawable/vector_icon" android:gravity="center" /> </layer-list> </item> </ripple> <style name="FullFABStyle"> <item name="fabSize">normal</item> <item name="maxImageSize">@dimen/fab_size</item> <item name="fabCustomSize">@dimen/fab_size</item> </style> <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="@dimen/fab_size" android:layout_height="@dimen/fab_size" style="@style/FullFABStyle" app:srcCompat="@drawable/your_background" /> 所以,你不需要覆盖 dimen 这个方法也行。 在 drawable 中创建一个名为 fab_background.xml 的形状,您可以在其中进行所需的所有自定义操作 <?xml version="1.0" encoding="utf-8"?> <shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android"> <size android:width="150dp" android:height="150dp"/> <gradient android:startColor="@color/colorAccentDark" android:endColor="@color/colorAccent"/> </shape> 在布局中创建一个名为 custom_fab.xml 的布局,然后使用图像视图设置背景和 fab 图标 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="50dp" android:layout_height="50dp" android:gravity="center" android:background="@drawable/fab_background" > <android.appcompat.widget.AppCompatImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/right" /> </LinearLayout> 然后您可以使用include引用它 例子 <?xml version="1.0" encoding="utf-8"?> <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:background="@drawable/background" android:orientation="vertical"> <include layout="@layout/custom_fab" android:layout_width="45dp" android:layout_height="45dp" android:layout_alignParentEnd="true" android:layout_alignParentBottom="true" android:layout_margin="32dp"/> </RelativeLayout> floatingActionButton: FloatingActionButton( child: Container( width: double.infinity, height: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), gradient: LinearGradient( begin: Alignment.bottomLeft, end: Alignment.topRight, colors: [ Color.fromRGBO(55, 59, 68, 1), Color.fromRGBO(66, 134, 244, 1) ]), ), child: Icon(Icons.add)), onPressed: () => _startAddNewTransaction(context), ), 使用 CardView 代替涟漪效应: <androidx.cardview.widget.CardView android:layout_width="56dp" android:layout_height="56dp" android:clickable="true" android:focusable="true" android:foreground="?android:attr/selectableItemBackground" app:cardCornerRadius="28dp" app:cardElevation="12dp" app:cardUseCompatPadding="false"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/fab_gradient"> <ImageView android:layout_width="24dp" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/icon_svg" app:tint="@color/white" /> </RelativeLayout> </androidx.cardview.widget.CardView> 以上答案不适用于 SVG,您可能还会看到拉伸的图标等。根据 fab 的材料设计,这是我用于我的应用程序的一种巧妙方法: 提示: 如果它没有出现在你想要的图层上方,请使用 elevation 属性。 对于那些仍然有这个问题的人,实现这个的简单解决方案是通过设置FAB的foreground。 像下面这个例子: <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:foreground="@drawable/circle_btn_gradient" /> 可绘制代码(circle_btn_gradient.xml): <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <gradient android:startColor="#2F8FC5" android:endColor="#1FCEB9" android:angle="270" /> </shape> </item> <item android:drawable="@drawable/baseline_add_24" android:top="15dp" android:left="15dp" android:right="15dp" android:bottom="15dp"> </item> </layer-list>

回答 8 投票 0

如何使用快速拨号动画在Android中创建像浮动操作按钮的收件箱

我想创建一个浮动动作按钮,动画显示内部快速拨号按钮,如谷歌开发的Inbox android应用程序。例:

回答 2 投票 0

FloatingActionButton图标动画(Android FAB src可绘制动画)

我试图找到有关如何创建FAB(设计支持库)的图标动画的文档,经过一段时间的搜索,我找不到任何关于它的信息和...

回答 2 投票 9

颤动 - 中心的FloatingActionButton

是否可以将FloatingActionButton留在中心而不是右侧? import'package:flutter / material.dart'; import'number.dart'; import'keykey.dart'; class ContaPage ...

回答 6 投票 5

浮动操作栏没有动画显示Snackbar?

在我的Android应用程序中,我使用了Clans的第三方库中的浮动操作按钮。喜欢 -

回答 1 投票 1

锚定到应用栏的FAB在向上滚动时不会隐藏

我已将FAB锚定到AppBarLayout。但是,在向上滚动时,FAB的预期行为是在工具栏折叠时隐藏。这不会发生。这是否必须特别处理? ...

回答 4 投票 4

© www.soinside.com 2019 - 2024. All rights reserved.