在Android中为appbar布局创建阴影

问题描述 投票:0回答:1

我正在创建一个需要在这样的应用栏布局中添加阴影的应用

enter image description here

但是我得到的不是这个:

enter image description here

这是我使用的代码

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    android:layout_marginEnd="16dp"
    android:backgroundTint="@color/colorPrimary"
    android:elevation="32dp"
    android:outlineProvider="bounds"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/search_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:autofillHints="no"
            android:backgroundTint="@color/colorPrimary"
            android:ems="10"
            android:hint="@string/search_text_hint"
            android:inputType="textPersonName"
            android:textColor="#DBFFFFFF"
            android:textColorHint="#D44A4A4B" />
    </Toolbar>


</com.google.android.material.appbar.AppBarLayout>
android android-layout
1个回答
0
投票
用您的代码代替android:elevation="32dp",请使用app:elevation="32dp"
© www.soinside.com 2019 - 2024. All rights reserved.