浮动操作按钮不显示矢量资源

2024-04-16

I'm trying to setup a vector asset into a fab. But the result is like this: enter image description here As you can see the vector is there but way down and to the left. here is the layout

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="@color/colorBg"
    tools:context=".ui.main.fragments.HomeFragment">


    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab_new_sale"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="16dp"
        app:backgroundTint="@color/colorAccent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:srcCompat="@drawable/ic_cart_plus"
        android:scaleType="center"/>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_home_cards"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:foregroundGravity="center_vertical|center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

这是向量:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="200dp"
    android:height="200dp"
    android:viewportWidth="200"
    android:viewportHeight="200">
    <path
        android:fillColor="#FF000000"
        android:pathData="M165.1,119.28L75,119.28l2,9.84h82.48a7.37,7.37 0,0 1,7.19 9l-1.7,7.46a17.2,17.2 0,1 1,-19.54 3.19L81,148.77a17.21,17.21 0,1 1,-20.6 -2.63L38.85,40.62L17.38,40.62A7.38,7.38 0,0 1,10 33.24L10,28.33A7.37,7.37 0,0 1,17.38 21h31.5a7.38,7.38 0,0 1,7.23 5.9l2.81,13.77h120.7a7.37,7.37 0,0 1,7.19 9l-14.52,63.91A7.38,7.38 0,0 1,165.1 119.28ZM135.38,72.58L120.63,72.58L120.63,60.28a4.92,4.92 0,0 0,-4.92 -4.91h-4.92a4.91,4.91 0,0 0,-4.91 4.91v12.3L91.13,72.58a4.91,4.91 0,0 0,-4.92 4.91v4.92a4.92,4.92 0,0 0,4.92 4.92h14.75L105.88,99.62a4.91,4.91 0,0 0,4.91 4.91h4.92a4.92,4.92 0,0 0,4.92 -4.91L120.63,87.33h14.75a4.92,4.92 0,0 0,4.91 -4.92L140.29,77.49A4.91,4.91 0,0 0,135.38 72.58Z" />
</vector>

对于此问题的任何帮助,我将不胜感激


Set

android {
   defaultConfig {
     vectorDrawables.useSupportLibrary = true
    }
 }

in your build.gradle

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

浮动操作按钮不显示矢量资源 的相关文章

随机推荐

  • 如何在Python 3.6中安装Keras?

    我在安装 Python 3 6 的 Keras 库时遇到问题 每当我尝试安装 Keras 时 它都会抛出错误 当我在互联网上搜索时 Keras 已发布到 Python 3 5 有人有解决方案吗 如果您有 Anaconda 和 Python
  • 当启用删除、插入或更新操作时,LinqDataSource 不支持 Select 属性

    我在单击删除按钮 链接时收到此错误GridView控制 LinqDataSource DataSource 不支持 Select 属性 删除 插入或更新操作已启用 我真的不明白为什么会收到此错误 因为我已经在网站的不同网页上做了同样的事情
  • 键盘中断张量流运行并在此时保存

    有没有办法通过键盘中断来中断张量流会话 并可以选择在此时保存模型 我目前让会话运行过夜 但需要停止它 以便我可以释放内存供电脑在白天使用 随着训练的进行 每个时期都会变慢 因此有时我可能需要等待几个小时才能进行程序中的下一个计划保存 我想要
  • 为 android 4.0 或更高版本创建自定义锁屏?

    我想为 android 4 0 及以上版本创建自定义锁屏 我尝试使用小部件来创建锁屏 但它仅支持 android 4 2 还有其他方法可以创建自定义 Android 锁屏吗 几个月前我在互联网上的某个地方找到了一些片段 我做了一些更改 最近
  • openlayers 地图未在 vuejs 中显示

    以下代码片段是一个 vue 文件 它不会生成任何错误 但 openlayers 地图不会显示 我尝试了 openlayers 的两个 vue 插件 但似乎没有按照我的需要工作 在 vue 之外 代码可以工作 我使用 npm install
  • Google Sheets 数据透视表未更新

    我有一个谷歌应用程序脚本 它将信息提交到有组织的工作表 并希望创建一个包含工作表中所有信息的数据透视表 我可以这样做 但每当我向工作表提交新行数据时 它都不会自动包含在数据透视表中 每次提交新行数据时 我都必须手动更改数据透视表的范围 有什
  • Android:检测打开的键盘,onApplyWindowListener 不起作用

    我试图在键盘打开时隐藏布局底部的一个特定按钮 以便为用户提供更多视图 随着发布androidx core core ktx 1 5 0 alpha02谷歌 最后 添加了一个名为的方法insets isVisible WindowInsets
  • 如何访问在 Amazon ec2 上运行的 django 应用程序?

    所以 我查看了堆栈溢出 其他网站 但无法解决这个问题 因此发布这个问题 我最近开始学习 django 并且现在尝试在 ec2 上运行它 我有一个以下格式的 ec2 实例 ec2 xx xxx xx xxx us west 2 compute
  • 如何使用 Fitch 系统证明 ((p ⇒ q) ⇒ p) ⇒ p

    仅供参考 我使用的逻辑程序无法进行矛盾引入 这一点很可能是无关紧要的 因为我非常怀疑我是否需要使用任何形式的矛盾来证明这一点 在尝试解决这个问题时 我首先假设 p q p 它是否正确 如果是这样 接下来怎么办 如果解决方案看起来如此明显 请
  • “GONE”视图是否会损害性能?

    我正在制作一个应用程序 它可以节省我一些时间 多个活动有一个布局 其中一些视图设置为 GONE 消失 具体取决于正在使用的活动 我知道布局中包含大量视图可能会导致性能不佳 如果我有一个具有大量视图的活动 但其中很大一部分视图都消失了 那么该
  • 在 uiimageview 中加载大图像时的内存消耗

    我正在使用 UIViewContentModeScaleAspectFit 将大小为 2480 3508 的 UIImage 加载到 UIImageView 中 我在加载此图像时收到内存警告 当我在此 UIImageView 中加载一些此尺
  • 如何从列类型列表中的 pandas DataFrame 中删除空值

    只是期待一个从具有列表值的列中删除空值的解决方案 从某种意义上说 我们已经事先替换了一些字符串 它是列表的字符串表示形式的列 In df color我们只是更换 Blue带空字符串 示例数据框 df pd DataFrame Bird pa
  • Visual Studio 2012 Ultimate 新依赖图错误

    每次使用 Visual Studio 2012 Ultimate 创建新的依赖关系图时 我都会收到此错误 Unable to connect to the specified database An exception occurred a
  • 在Python中插入lxml树时出现属性错误

    我正在尝试将 xml 的小结构注入到现有 xml 文件中的特定位置
  • href 链接不可点击或不可突出显示

    我不完全确定为什么我的 a href 链接不起作用 在某个时间点它起作用了 我对 Z Index 做了一些研究 但这似乎不是问题 也不是我有一个重叠的 div 吗 请访问JSFIDDLE NET https jsfiddle net t9v
  • Ajax 如果超过一个 @mention

    我正在尝试使用 jquery ajax php 制作一个 facebook 和 twitter 风格的提及系统 但如果我尝试 提及多个用户 我就会遇到问题 例如 如果我开始输入如下内容 Hi stack how are you 结果显示 s
  • 将列添加到现有红移表

    我有一个包含超过 30m 条记录的数据库 我需要向数据库添加两个新列 问题是我需要这些列不为空 并且没有默认值 我以为我只需添加这些没有 NOT NULL 约束的列 用数据填充它们 然后添加约束 但 Redshift 不支持这一点 我心里有
  • 如何使用代码在 ios 应用程序中录制屏幕视频?

    就像苹果商店中的 ShowMe 应用程序一样 用户可以绘画并将动作录制为视频 你们知道如何在代码中做到这一点吗 谢谢 我们最近遇到了这个问题 并发现了一篇精彩的文章 其中使用了视图层和媒体框架 在这里查看链接 http codethink
  • Swift 协议只能设置吗?

    为什么我可以毫无错误地执行此操作 var testDto ModelDto modelId 1 testDto objectId 2 当我定义这个时 protocol DataTransferObject var objectType Dt
  • 浮动操作按钮不显示矢量资源

    I m trying to setup a vector asset into a fab But the result is like this As you can see the vector is there but way dow