【问题标题】:FloatingActionButton elevation not working on pre-lollipop devicesFloatingActionButton 高程在棒棒糖之前的设备上不起作用
【发布时间】:2016-09-15 12:13:40
【问题描述】:
  <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout 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:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:minHeight="56dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:titleTextAppearance="@style/ToolbarTitle" >
</android.support.v7.widget.Toolbar>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/myFAB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="8dp"
        android:clickable="true"
        android:layout_marginBottom="8dp"
        android:src="@drawable/ic_fab_star"
        app:borderWidth="0dp"
        app:elevation="10dp"
        />
    <RelativeLayout
        android:id="@+id/relative6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </RelativeLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_below="@id/relative6"
        android:orientation="vertical">
        <ListView
            android:id="@+id/list_history"
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_gravity="start"
            android:layout_weight="1"
            android:clickable="false"
            android:cacheColorHint="@android:color/transparent"
            android:choiceMode="singleChoice"
            android:divider="@null"
            android:dividerHeight="0dp" />
    </LinearLayout>
</RelativeLayout>
 </LinearLayout>

这是我的 xml,高度不适用于棒棒糖之前的设备。

完美适用于新设备 nexus 5, 6 我测试了它们。

但不适用于运行 kit kat 的旧设备。

非常感谢您提供的任何帮助和富有成效的信息。

【问题讨论】:

  • 将此行添加到您的代码 app:fabSize="normal"

标签: android elevation


【解决方案1】:

只需设置app:borderWidth="0dp" 即可为我解决此问题。

注意:不要忘记将xmlns:app="http://schemas.android.com/apk/res-auto" 添加到您的根布局中。

它对我有用

<android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/your_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="@dimen/floating_button_margin_bottom"
        android:layout_marginRight="@dimen/floating_button_margin_right"
        app:elevation="@dimen/floating_button_elevation"
        app:borderWidth="0dp"
        app:rippleColor="@color/your_ripple_color"
        app:backgroundTint="@color/your_bg_color" />

【讨论】:

  • 它不能解决我的问题,我已经这样做了。检查我的代码。
  • 浮动按钮仍在我的列表视图下
  • 尝试将您的父布局更改为 RelativeLayout
  • 没有区别。
  • 尝试将app:pressedTranslationZ="12dp" @krikorHerlopian 添加到FloatingActionButton 的属性中
猜你喜欢
  • 2016-10-14
  • 2016-01-20
  • 1970-01-01
  • 2016-08-14
  • 1970-01-01
  • 2016-02-11
  • 2018-09-01
  • 2023-03-21
  • 1970-01-01
相关资源
最近更新 更多