【问题标题】:Cannot get elevation in BottomAppBar无法在 BottomAppBar 中获得高度
【发布时间】:2018-12-03 03:10:21
【问题描述】:

如何获取 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 material-design material-components android-bottomappbar


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2017-04-11
    • 1970-01-01
    • 1970-01-01
    • 2012-10-07
    • 2018-10-09
    • 2011-01-30
    • 2015-10-04
    • 2016-07-11
    • 1970-01-01
    相关资源
    最近更新 更多