Android:自定义视图阴影

时间:2020-04-10 15:51:18

标签: android

我正在尝试使用高程在我的自定义视图中添加阴影。 该视图应显示在屏幕底部,并在其顶部阴影。

我已在清单中启用了硬件加速

android:hardwareAccelerated="true"

然后,我创建了一个名为MenuPanel的自定义视图-该视图应显示在底部并放置顶部阴影:

<androidx.recyclerview.widget.RecyclerView 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:id="@+id/menuList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/panel_background"
    android:orientation="vertical"
    app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
    app:reverseLayout="false"
    app:spanCount="6"
    tools:listitem="@layout/panel_button" />

然后我将MenuPanel添加到它的paren-ControlPanel中,方法如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:animateLayoutChanges="true"
    android:background="@android:color/transparent"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/panelsHolder"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <com.andreyserdyuk.posstation.views.presets_panel.PresetsPanel
            android:id="@+id/presetsPanel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:visibility="invisible" />

        <com.andreyserdyuk.posstation.views.keyboard_panel.KeyboardPanel
            android:id="@+id/keyboardPanel"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_alignParentBottom="true"
            android:visibility="invisible" />

        <com.andreyserdyuk.posstation.views.member_panel.MemberPanel
            android:id="@+id/memberPanel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:visibility="invisible" />

        <com.andreyserdyuk.posstation.views.coupon_panel.CouponPanel
            android:id="@+id/couponPanel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:visibility="invisible" />
    </RelativeLayout>

    <com.andreyserdyuk.posstation.views.menu_panel.MenuPanel
        android:id="@+id/menuPanel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="12dp" />
</LinearLayout>

什么也没被刺破。

我做错了什么?帮帮我,请解决这个问题-为MenuPanel蒙上阴影。 谢谢!

0 个答案:

没有答案
相关问题