android – 在支持库中设置FloatingActionButton的边框颜色

android – 在支持库中设置FloatingActionButton的边框颜色,第1张

概述在支持库中引入了 FloatingActionButton.可以选择使用app设置按钮的边框宽度:borderWidth =“2dp”,但是如何设置边框颜色? 我为该porpuse创建了一个自定义drawable,例如: <item> <shape android:shape="oval"> <solid android:color="@color/color1" /> 在支持库中引入了 FloatingActionButton.可以选择使用app设置按钮的边框宽度:borderWIDth =“2dp”,但是如何设置边框颜色?

我为该porpuse创建了一个自定义drawable,例如:

<item>     <shape androID:shape="oval">         <solID androID:color="@color/color1" />         <stroke androID:wIDth="2dp" androID:color="@androID:color/white" />     </shape></item>

并尝试使用androID:background和app:floatingActionbutton的backgroundTint属性来设置背景.他们没有工作.请注意,app:backgroundTint似乎只是为了接受颜色而不是可绘制的

有人知道任何解决方法吗?

解决方法 你试过androID:src属性吗?
试试这个
<androID.support.design.Widget.floatingActionbutton    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:src="@drawable/your_drawable"    andriod:scaleType="center"  /> <!-- You need to scale your src. ->

我希望它能奏效.

编辑

<?xml version="1.0" enCoding="utf-8"?><@R_414_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID">    <item androID:drawable="@drawable/your_icon" /> <!-- include your icon here -->    <item>        <shape androID:shape="oval"> <!-- or rectangle -->            <stroke                androID:wIDth="2dp"                androID:color="@androID:color/white" />        </shape>    </item></@R_414_3419@>

您可以将图标添加到可绘制的形状xml中.并为您的图标添加边框并将其应用于FAB.

我在我的形状文件中添加了一个hdpi图标,这是我得到的结果.

根据谷歌的设计规格,实际的可绘制尺寸应为24dp.

总结

以上是内存溢出为你收集整理的android – 在支持库中设置FloatingActionButton的边框颜色全部内容,希望文章能够帮你解决android – 在支持库中设置FloatingActionButton的边框颜色所遇到的程序开发问题。

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

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

原文地址: http://www.outofmemory.cn/web/1135616.html

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

发表评论

登录后才能评论

评论列表(0条)

保存