android - 无法使布局宽度与我在 XML 上的文本相同
问题描述
我已经开始学习 xml,虽然我使用线性布局并将其 layout_width 设置为 wrap_content,并且还使用我的文本视图的布局宽度作为 wrap_content,但它覆盖了我的屏幕的整个宽度(宽度方向)。
注意:- 仅当我选择垂直方向时才会发生这种情况。有什么我想念的吗?
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#D2B48C"
android:orientation="vertical">
<TextView
android:text="sahil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#DC143C"/>
</LinearLayout>
以上是我的代码。
这是图像:- 我上面编写的代码的xml结果
解决方案
推荐阅读
- php - 如何将数据库导入phpmyadmin
- node.js - 如何从 Fastify POST 请求正文中检索 excel .xlsx 数据?
- mysql - 使用计数和最大值功能查询
- python - 位于 Google Ads 中的硒元素
- python - 使用 multiprocessing.manangers.BaseManager 作为 docker-compose 编排的一部分
- python - Python 数组,获取每 n 个条目,然后移动到下一个 n 条目,直到数组末尾
- bash - iptables -mac 地址接受循环
- android - Apache FTPSClient Android 11
- python - 使用 pandas 将 .dat 文件转换为 csv 格式的问题,需要将 1 列拆分为多列
- sorting - 我们可以通过从日志中解析,使用 datadog 的日期列以及创建的自定义时间戳列创建 Datadog 日志视图吗?