【问题标题】:How can I create a border around an Android layout like attached image? [closed]如何在 Android 布局(如附加图像)周围创建边框? [关闭]
【发布时间】:2017-04-24 05:28:58
【问题描述】:

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

如何创建像附加图像一样的边框?

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

【问题讨论】:

    标签: android list border shape layer


    【解决方案1】:

    试试这个:

    第一步:用空白数据创建9patch边框图片here

    第 2 步:在布局背景中设置此图像并管理顶部、左侧、右侧和底部的填充

    【讨论】:

      【解决方案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">
      

      希望这会有所帮助。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-08
      • 2018-07-21
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-15
      相关资源
      最近更新 更多