android - Floating Action Button is translucent for some reason
问题描述
I have two Floating Action Buttons in my layout, but for some reason, the two buttons are semi-transparent.
I was wondering how to make the buttons solid? Here's the source code for the layout file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_assignment_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="@drawable/ic_add_white_24dp"
app:useCompatPadding="true" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/start_session_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:src="@drawable/ic_play_arrow_white_24dp"
app:layout_anchor="@id/add_assignment_button"
app:layout_anchorGravity="top"
app:useCompatPadding="true"></android.support.design.widget.FloatingActionButton>
</LinearLayout>
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
</android.support.design.widget.CoordinatorLayout>
解决方案
浮动操作按钮由于某种原因是半透明的
移动您的FloatingActionButton
外部线性布局也无需使用LinearLayout
使您的布局如下所示
示例代码
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_assignment_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="20dp"
android:src="@drawable/ic_menu_send"
app:useCompatPadding="true" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/start_session_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:src="@drawable/ic_menu_send"
app:layout_anchor="@id/add_assignment_button"
app:layout_anchorGravity="top"
app:useCompatPadding="true" />
</android.support.design.widget.CoordinatorLayout>
输出
推荐阅读
- google-chrome - 在 Chromecast 上投射带有自动播放非静音视频的网页
- python - python json格式错误,“TypeError:字符串索引必须是整数”
- design-patterns - 使用捕获模式匹配来改变 Vec 元素
- python - 当我读取 .csv 表时,我的数据帧上有多个“\t”
- python - 有人可以向我解释为什么我的 django 管理主题是黑暗的吗?
- laravel - 如何在 laravel 5.5 中获取当前插入的行 ID
- css - jekyll 主题 CSS 在 github io 页面中不起作用
- http - 后缀日志:来自未知 IP 地址的非 SMTP 命令,“GET /aaa9 HTTP/1.1”
- javascript - 同时执行两个方法
- java - Java:对象数组,两种不同的初始化方法