添加阴影在Android上自定形状自定、形状、阴影、Android

由网友(ん無法⌒離開妳)分享简介:是否有可能阴影添加到Android的自定义形状?后翻翻文件,我只看到了一种应用文本阴影。我已经试过这没有运气:< XML版本=1.0编码=UTF-8&GT?;<形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android机器人:形状=矩形>[固体机...

是否有可能阴影添加到Android的自定义形状?后翻翻文件,我只看到了一种应用文本阴影。

我已经试过这没有运气:

 < XML版本=1.0编码=UTF-8&GT?;
   <形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
   机器人:形状=矩形>
     [固体机器人:颜色=#90ffffff/>
       <边角机器人:半径=12dp/>
     <项目名称=安卓则shadowColor>#000000< /项目>
     <项目名称=机器人:shadowRadius> 5℃/项目>
     <项目名称=机器人:shadowDy>第3版; /项目>
   < /形状>
 

解决方案

在很多搜索最终我得到了这个

 < XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>

<! - 底2DP阴影 - >
<项目>
    <形机器人:形状=矩形>

        [固体机器人:颜色=#d8d8d8/>
        <边角机器人:半径=7DP/>

    < /形状>
< /项目>

<! - 白顶的颜色 - >
<项目安卓底=的3px>

    <形机器人:形状=矩形>

    [固体机器人:颜色=#FFFFFF/>
    <边角机器人:半径=7DP/>


    < /形状>

< /项目>


< /层列表>
 
Android 添加自定义代码块

Is it possible to add a drop shadow to a custom shape in Android? After looking through the documentation, I only see a way to apply a text shadow.

I've tried this with no luck:

<?xml version="1.0" encoding="UTF-8"?> 
   <shape xmlns:android="http://schemas.android.com/apk/res/android" 
   android:shape="rectangle"> 
     <solid android:color="#90ffffff"/>
       <corners android:radius="12dp" />
     <item name="android:shadowColor">#000000</item> 
     <item name="android:shadowRadius">5</item> 
     <item name="android:shadowDy">3</item> 
   </shape>

解决方案

After Lots of search finally I got this

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Bottom 2dp Shadow -->
<item>
    <shape  android:shape="rectangle">

        <solid android:color="#d8d8d8" />
        <corners android:radius="7dp" />

    </shape>
</item>

<!-- White Top color -->
<item android:bottom="3px">

    <shape  android:shape="rectangle">

    <solid android:color="#FFFFFF" />
    <corners android:radius="7dp" />


    </shape>

</item>


</layer-list>

阅读全文

相关推荐

最新文章