Android 添加投影、阴影背景时显示不正确的问题

遇到一个需求,弹出的菜单框背景需要添加阴影效果,然后让设计师切了.9图的阴影背景图。

然后,图底部的阴影效果能显示出来,左侧、右侧、上侧的阴影效果却怎么也显示不出来。

后来我发现,这个弹框的布局是外层是线性布局,然后包裹了一个ListView,而这个阴影,我作为了了外层的线性布局的背景。

而当我把阴影图作为ListView的背景时,四个方向的阴影效果就显示出来了。

这个应该涉及到背景的相关概念问题,暂时不是特别清楚,先记录一下。后续再思考。

附:

布局文件内容:(这样的是不能正确显示阴影效果的)

<?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="wrap_content"
   android:padding="1dp"
              android:background="@drawable/bg_shadow_mid"
    android:orientation="vertical" >
    <ListView 
        android:id="@+id/order_listview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@color/common_line1"
        android:dividerHeight="1dp"

        />

</LinearLayout>
发布了22 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/yeziyfx/article/details/91433636
今日推荐