【发布时间】:2016-04-01 04:30:41
【问题描述】:
我通过下载包含 24dp 图标的 png drawables 的存档,从 android 支持库和 material icons site 的添加图标创建了材质浮动操作按钮。
这是我创建 FAB 的代码:
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:elevation="6dp"
android:src="@drawable/ic_add"
app:fabSize="normal"
android:layout_gravity="bottom|right"
app:layout_anchorGravity="bottom|right|end"
app:pressedTranslationZ="12dp">
</android.support.design.widget.FloatingActionButton>
这是它在 xml 设计选项卡中的呈现方式:
我能做的不多,因为我有正确的按钮 xml 语法,而且图标显然是透明的,周围没有黑色背景。
【问题讨论】:
-
在真机上看起来如何?还是模拟器? Xml 对我来说看起来不错
-
我认为这个问题来自使用过的图像而不是来自代码,你的代码似乎很好
-
我使用了材料设计图标中的图像。 google.com/design/icons
-
@MinaFawzy 谢谢!您发布的链接中的图标有效!您也是从材料设计图标网站获得的吗?
标签: android material-design floating-action-button