如何在android中显示底部阴影?

Dar*_*iya 0 android

如何在android中创建这种类型的布局看起来像图像

在此输入图像描述:

Jay*_*ola 7

使用MaterialCardView和使用cardElevation

将其添加到 gradle 文件中以供使用material components

implementation 'com.google.android.material:material:1.2.0-alpha03'
Run Code Online (Sandbox Code Playgroud)

样式.xml

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

在你的xml中

 <com.google.android.material.card.MaterialCardView
            android:id="@+id/card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:strokeWidth="1dp"
            app:strokeColor="@color/stroke_color"
            app:cardElevation="10dp"
            android:layout_margin="8dp">

            //add some view

        </com.google.android.material.card.MaterialCardView>
Run Code Online (Sandbox Code Playgroud)