0

我正在尝试使用 com.google.material 库创建一个底部应用栏并成功创建,但问题出在 Bar Shadow 形状的顶部或海拔不适用。我搜索了过去 2 天,但没有找到任何关于我的问题的解决方案。我还会附上一张我想要底部应用栏设计的图片。请帮我解决在此处输入图像描述这个问题,我是android开发的新手。

`

<?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=".activities.HomeActivity">
    <com.google.android.material.bottomappbar.BottomAppBar
        android:elevation="@dimen/dp10"
        android:id="@+id/bottom_app_bar"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_gravity="bottom"
        app:backgroundTint="@android:color/white"
        android:fadingEdge="vertical"
        android:paddingEnd="53dp"
        android:paddingStart="53dp"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:id="@+id/iconlayout"
                android:layout_centerVertical="true"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content">
                    <ImageView
                        android:id="@+id/home_icon"
                        android:src="@drawable/ic_home_active"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></ImageView>
                    <!-- <ImageView
                         android:layout_marginRight="12dp"
                         android:id="@+id/bullets_img_home"
                         android:layout_marginTop="5dp"
                         android:src="@drawable/ic_blue_bullet"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"></ImageView>-->
                </LinearLayout>
                <LinearLayout
                    android:layout_gravity="center"
                    android:orientation="vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <ImageView
                        android:id="@+id/menu_icon"
                        android:src="@drawable/ic_menu_inactive"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></ImageView>
                    <!-- <ImageView
                         android:visibility="gone"
                         android:id="@+id/bullets_img_menu"
                         android:layout_marginTop="5dp"
                         android:layout_gravity="center"
                         android:src="@drawable/ic_blue_bullet"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"></ImageView>-->
                </LinearLayout>

            </LinearLayout>
            <RelativeLayout
                android:animateLayoutChanges="true"
                android:id="@+id/view_layout"
                android:layout_marginTop="3dp"
                android:layout_below="@+id/iconlayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <RelativeLayout
                    android:background="@drawable/dotbtn"
                    android:layout_marginLeft="11dp"
                    android:layout_marginRight="12dp"
                    android:layout_alignParentStart="true"
                    android:id="@+id/bullets_img_menu"
                    android:layout_gravity="center"
                    android:layout_width="4dp"
                    android:layout_height="4dp"></RelativeLayout>
            </RelativeLayout>
        </RelativeLayout>
    </com.google.android.material.bottomappbar.BottomAppBar>
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:backgroundTint="@color/main_color"
        android:src="@drawable/plusicon"
        app:fabCustomSize="65dp"
        app:borderWidth="0dp"
        android:adjustViewBounds="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_anchor="@id/bottom_app_bar" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="40dp"></FrameLayout>
    </LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

这是我的布局代码`

4

1 回答 1

1

最后我找到了一个解决方案,我只需将我的 com.material.google 库版本更新为实现 'com.google.android.material:material:1.3.0-alpha01' 并完美显示阴影

于 2020-12-05T06:13:47.173 回答