android - 无法在 BottomAppBar 中获得提升

标签 android material-design material-components android-bottomappbar

如何获取 BottomAppBar 的高度。我认为默认情况下它的高度为 8dp,但我没有得到任何高度。 这是我的代码。

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottom_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"
        style="@style/Widget.MaterialComponents.BottomAppBar" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_anchor="@id/bottom_bar"
        android:src="@android:drawable/ic_input_add"
        android:tint="@color/colorPrimary"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

最佳答案

部分问题在于照明系统在 Android 上的工作方式。顶部有一个光源,中间有一个光源。这意味着阴影通常在 View 顶部不可见。

我们有一个错误来伪造 BottomAppBar 的阴影,但它并不像 BottomNavigation 那样微不足道,因为 fab 可以移动和改变形状,所以阴影也应该改变。

关于android - 无法在 BottomAppBar 中获得提升,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51008277/

相关文章:

android - 尝试从 Material Components 渲染 MaterialButton 时出错

android - 右侧带有图标的 Material 按钮

c# - MDCTabBar 和 MDCNavigationBar 将 NavigationBar 向上推

android - CollapsingToolbarLayout 中的多行 TextView 而不是标题

android - 在 android 中使用 Http Post 发送表单数据 Post 请求

java - 布局无法正常工作

php - 将 Java 中的 RSA 公钥发送到 PHP 服务器

android - 为 RecyclerView-Item 创建选项菜单

css - Angular:如何使用查询参数过滤数据表

android - 通过选择另一个回收器 View 来更改一个回收器 View 中的值