【发布时间】:2015-09-21 01:09:40
【问题描述】:
当我为我的工厂设置颜色时,它看起来像这样:
我的布局 xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"
android:layout_marginRight="20dp"
app:fabSize="normal"
android:elevation="@dimen/fab_elevation"
android:background="#000000"
android:stateListAnimator="@animator/fab_anim"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
颜色也不会改变。 谁能帮助我理解我做错了什么?
我也尝试使用@color 链接,但它崩溃了,背景为可绘制的(ex. android:background="@drawable/fab_background") 没有任何反应。
这是可绘制的fab_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="@color/fab_color_1_muted">
<item>
<shape>
<solid android:color="@color/fab_color_1" />
</shape>
</item>
</ripple>
</item>
【问题讨论】:
-
将
app:borderWidth="0dp"添加到布局中。 -
解决了吗?或者您期望的行为是什么?
标签: android button action floating floating-action-button