在Android开发中,我们想为控件添加边框,可以使用Shape。

首先,我先简单介绍一下Shape。

solid:填充

gradient:渐变

stroke:描边

corners:圆角

padding:间隔

Shape的使用如下,制作椭圆形边框textview_bg.xml。

android:width="1dp"

android:color="#000000" />

android:bottomLeftRadius="5dp"

android:bottomRightRadius="5dp"

android:topLeftRadius="5dp"

android:topRightRadius="5dp" />

android:bottom="4dp"

android:left="4dp"

android:right="4dp"

android:top="4dp" />

为TextView添加Shape制作好的椭圆形边框。

android:background="@drawable/textview_bg"

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐