Android:使用更大的图标创建更大的Floating Action Button [英] Android: Create bigger Floating Action Button with bigger icon

查看:91
本文介绍了Android:使用更大的图标创建更大的Floating Action Button的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个更大的浮动操作按钮"(FAB),比通常的56 dp更多,并在其中添加一个更大的图标. (出于我的目的,图标永远是不言自明的,因此我将创建一个包含短文本的png文件,并使用此png作为图标.)

I want to create a bigger Floating Action Button (FAB), more than the usual 56 dp, with a bigger icon inside. (For my purpose an icon will never be self-explanatory so I will create a png-file containing a short text and use this png as icon.)

增加FAB的大小可以正常工作:
因为我不使用mini-FloatingActionButton,所以我重新定义了mini-button-size.
在我的 layout-xml 中,我指定:

Increasing the size of the FAB works fine:
as i don't use the mini-FloatingActionButton, i redefined the mini-button-size.
in my layout-xml i specify:

<android.support.design.widget.FloatingActionButton
    ...
    app:fabSize="mini"
    ....

dimensions.xml 中,我重新定义了小型晶圆厂的大小:

and in the dimensions.xml i redefine the size for the mini-fab:

<dimen name="fab_size_mini">80dp</dimen>

但是,我没有设法在FAB上获得更大的图标. 我尝试了与材料图标库中具有不同dp的图标-没有成功.在FAB布局上设置填充也无效.

However, I didn't manage to get a bigger icon on the FAB. I tried icons with different dp's from the material icons library - no success. Also setting a padding on the FAB-layout did not work.

有什么建议吗?谢谢!

推荐答案

您可以尝试在dimensions.xml中重新定义fab映像大小的最大大小:

You can try to redefine the maximum size of the fab image size in your dimensions.xml:

<resources xmlns:tools="http://schemas.android.com/tools">
    <dimen name="design_fab_size_mini" tools:override="true">80dp</dimen>
    <dimen name="design_fab_content_size" tools:override="true">48dp</dimen>
</resources>

必须确保您覆盖设计库中的原始资源.如果这对您不起作用,请尝试使用design_fab_image_size而不是design_fab_content_size.

Must make sure you override the original resources in the Design Library. Try design_fab_image_size instead of design_fab_content_size if this does not work for you.

请谨慎使用,因为这不是真正的解决方案.如果在将来的设计库发行版中更改了资源名称,则解决方案可能不起作用.我的观点是坚持使用设计库中定义的大小,因为这是基于材料设计"的推荐设计指南,可让您的整体应用看起来不错.

Use with care as this is a hack not an actual solution. Solution might not work if the resource's name is changed in the future Design Library release. My opinion is to stick with the size that is define in the Design Library as it is the recommended design guideline based on the Material Design which make your overall app looks good.

这篇关于Android:使用更大的图标创建更大的Floating Action Button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆