阴影布局,9补丁和背景颜色透明?

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

我想添加一个自定义布局边缘阴影,正好像这样:http://inloop.github.io/shadow4android/

问题是我使用它来添加半/透明背景颜色:(corners_main_layout.xml)

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="6dp" />
<solid android:color="@color/bright_foreground_disabled_material_dark" />
</shape>

所以我不能用于后台9补丁。

有没有办法用阴影和透明背景颜色9补丁?

如果不是......怎么能产生效果?

PS:我看过很多自定义XML来添加阴影,但都非常差。

这里的例子:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_recover_pass"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="...RecoverPassActivity"
android:background="@mipmap/fondo_01"
android:orientation="vertical">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/corners_main_layout">

</LinearLayout>

enter image description here

我需要阴影边框矩形白色(它是透明的)类似于示例9补丁

------------编辑---------------我修改了mi corners_main_layout.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners android:radius="6dp" />
        <solid android:color="@color/bright_foreground_disabled_material_dark" />

    </shape>
</item>

<item android:drawable="@drawable/shadow_custom" />

结果:-(:enter image description here

android shadow nine-patch
1个回答
1
投票

是啊!我有解决方案!

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <corners android:radius="6dp" />
        <solid android:color="@color/bright_foreground_disabled_material_dark" />
    </shape>
</item>
<item android:drawable="@drawable/shadow_custom_9patch"/>
</layer-list>

感谢帮助!

© www.soinside.com 2019 - 2024. All rights reserved.