如何在附加图像(如附件图像)上创建边框



我需要创建边框布局时有问题,但是我不能。

如何创建像附件的边框?

https://i.stack.imgur.com/pv804.png

尝试以下:

步骤1:在此处使用空白数据创建9PATCH BORDER IMAGE

步骤2:将此图像设置在布局背景中,并从顶部,左,右和底部管理填充

您可以与所需的任何布局接壤。只需使用名称customborder的自定义布局,然后添加XML代码

 <?xml version="1.0" encoding="UTF-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
   <corners android:radius="20dp"/> 
   <padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
   <stroke android:width="1dp" android:color="#CCCCCC"/>
 </shape>

然后只需将背景添加到这样的布局中

<LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/customborder">

希望这会有所帮助。

最新更新