以下CSS, 在 android view xml 中怎么写?
黄舟
黄舟 2017-04-17 11:36:47
[Android讨论组]
border-radius: 5px;
background-image: linear-gradient(-179deg, #FAD961 0%, #F76B1C 100%);
border: 1px solid #8B572A;
box-shadow:         0px 1px 1px 0px rgba(0,0,0,0.30), inset 0px 1px 1px 0px rgba(255,255,255,0.60);
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
大家讲道理

安卓的xml文件里没有提供类似shadow的属性,所以只能取得近似的效果

下面是一个LayerDrawable文件,里面包含两个Rectangle

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

    <!-- 外阴影 -->
    <item>
        <shape android:shape="rectangle" >
            <solid android:color="#4c000000" />

            <corners android:radius="5dip" />
        </shape>
    </item>
    <!-- 背景 -->
    <item
        android:bottom="1dip"
        android:right="1dip">
        <shape android:shape="rectangle" >
            <gradient
                android:angle="270"
                android:endColor="#F76B1C"
                android:startColor="#FAD961" />

            <corners android:radius="5dip" />

            <stroke
                android:width="1dip"
                android:color="#8B572A" />
        </shape>
    </item>

</layer-list>

下面是布局代码

<?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:orientation="vertical"
    android:padding="10dp" >

    <TextView
        android:id="@+id/pview"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="@drawable/shadowp" />

</LinearLayout>

效果图:

说明:不知道怎么实现CSS中的内阴影,求大神告知!

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号