【发布时间】:2015-10-06 15:12:39
【问题描述】:
我正在实施 Fab。它显示在设备 API 但它没有显示在 API >= 21 的设备上
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@color/transparent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:background="@color/background_chart"
android:clickable="true">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/white_20"
android:dividerHeight="1dip"
android:footerDividersEnabled="false"
/>
</RelativeLayout>
<FrameLayout
android:id="@+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:background="@drawable/bottom_shadow"
android:foreground="@drawable/bottom_shadow" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_marginTop="@dimen/fab_margin_top"
android:layout_marginRight="@dimen/fab_margin_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_add"
app:borderWidth="0dp"
app:elevation="6dip"
app:pressedTranslationZ="12dp" />
</RelativeLayout>
如何为所有 api >=15 显示它?
编辑:
问题似乎是由两个原因引起的。
1)在棒棒糖前app:pressedTranslationZ="12dp" 向下移动FAB(如边缘顶部,在棒棒糖中它不再作为边缘顶部工作,蝙蝠改变按下状态的高度。
2) 按钮放置在高度为 4(工具栏)的布局下,我尝试为 FAB 设置不同的 app:elevation 和 android:elevation,但它没有任何改变。
【问题讨论】:
标签: android android-design-library floating-action-button