android给textview添加边框,Android:在textview周围添加边框

本文介绍了如何在Android中为TextView添加边框。通过创建XML形状 drawable 文件,设置矩形边框的颜色和宽度,然后将此边框用作TextView的背景。内容包括使用不同布局(如LinearLayout、ConstraintLayout)实现带边框的TextView,并解决边框与文本重叠的问题。
摘要由CSDN通过智能技术生成

如何使用xml布局在图片所示的文字周围添加边框

48f382419d4bdcc156e28f02e408518b.png

我尝试将边框添加到布局中,但与文本重叠。

aa1989aad46d99e06eabb35400c7e271.png

您可以使用形状可绘制

将textviews背景设置为白色,然后将其放在框上方

能否请您详细说明一下,我必须在该矩形内添加textviews

这回答了你的问题了吗? 如何在Android textview周围放置边框?

您可以尝试这种布局,它可以根据您的要求进行反映

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="15dp">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/border"

android:layout_marginTop="10dp"

android:orientation="vertical"

android:padding="15dp">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textStyle="bold"

android:text="Label 1: Value 1"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textStyle="bold"

android:text="Label 2: Value 2"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textStyle="bold"

android:text="Label 3: Value 3"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值