Linux 拨号vps windows公众号手机端

android阴影边框设置的方法是什么

lewis 8年前 (2017-01-06) 阅读数 10 #程序编程
文章标签 android

在Android中,可以使用elevation属性来设置阴影效果。elevation属性是View类中的一个属性,用于设置View的Z轴高度,从而产生阴影效果。例如:

<View
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="8dp"
    android:background="@android:color/white"/>

在上面的例子中,elevation属性设置为8dp,表示View的Z轴高度为8dp,从而产生一个阴影效果。可以根据需要调整elevation的数值来控制阴影的深浅程度。

另外,如果要设置View的边框,可以使用Stroke属性和StrokeColor属性来实现。例如:

<View
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:strokeWidth="2dp"
    android:strokeColor="@android:color/black"/>

在上面的例子中,strokeWidth属性设置为2dp,表示边框的宽度为2dp,strokeColor属性设置为@android:color/black,表示边框的颜色为黑色。可以根据需要调整strokeWidthstrokeColor的数值来设置边框的样式。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门