Jon*_*n I 5 android action button floating floating-action-button
当我为我的工厂设置颜色时,它看起来像这样:

我的布局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" />
Run Code Online (Sandbox Code Playgroud)
颜色也不会改变.谁能帮我理解我做错了什么?
我也尝试了一个@color链接,但它崩溃了,一个drawable的背景(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>
Run Code Online (Sandbox Code Playgroud)
在xml中使用此代码
应用程式:边框宽度= "0dp"
<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"
app:borderWidth="0dp"
android:stateListAnimator="@animator/fab_anim"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
Run Code Online (Sandbox Code Playgroud)
使用
app:backgroundTint="@android:color/holo_green_dark"
Run Code Online (Sandbox Code Playgroud)
(例如)设置 fab 的颜色。结果如下。取自这个经过测试的代码片段。

另请编辑:“奇怪的绿色”应该来自你的强调色。这是 fab 默认采用的颜色。
| 归档时间: |
|
| 查看次数: |
12430 次 |
| 最近记录: |