sách gpt4 ai đã đi

android - RelativeLayout 背景可绘制重叠内容

In lại 作者:可可西里 更新时间:2023-10-31 22:04:08 28 4
mua khóa gpt4 Nike

我有一个 9-patch drawable(date_time)。我想将此可绘制对象放在相对布局内容的后面,因此所有 subview 都应绘制在此图像之上。这是 xml 布局:

<>
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_below="@id/tv_map_address"
android:layout_marginTop="11dp"
android:layout_marginBottom="12dp"
android:background="@drawable/date_time">


android:id="@+id/iv_map_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_map_distance"/>


android:id="@+id/tv_map_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/iv_map_distance"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textSize="11sp"
android:text="2,7 км"
fontPath="fonts/Roboto-Medium.ttf"/>


android:id="@+id/iv_map_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/tv_map_distance"
android:layout_centerVertical="true"
android:src="@drawable/ic_map_path"/>


android:id="@+id/tv_map_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/iv_map_path"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textSize="11sp"
android:text="3,2 км"
fontPath="fonts/Roboto-Medium.ttf"/>


但不知何故,这个背景覆盖了所有子内容。这里显示了正在发生的事情。

Overlapping content

但是如果我替换

android:background="@drawable/date_time"

đến

android:background="#0000FF"

一切正常,接下来是输出:

nhập mô tả hình ảnh ở đây

你能解释一下我做错了什么吗?

更新:这是我的 9 补丁绘图。

nhập mô tả hình ảnh ở đây

1 Câu trả lời

正如我认为您的内容指示器不正确一样(除非您想在 9-patch 中引入这样的内容填充)。试试这个:

9-patch

右侧和底部指南,确定您的内容应占用 drawable 的哪一部分(或多少)。您已将此区域设置为非常小的空间,并设置了 Layout 的固定高度。换句话说:9-patch 强制您的 Layout 让它的 child 只占据您 View 的一小部分区域(这受到您不让您的 Layout 拉伸(stretch)的限制)。

关于android - RelativeLayout 背景可绘制重叠内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30167233/

28 4 0
Bài viết được đề xuất: php - centos如何在浏览器中打开HTML文件?
Bài viết được đề xuất: swift - 应用程序崩溃 - 未加载 AuthenticationServices 库
Bài viết được đề xuất: 带有垂直滚动条的html列表框
Bài viết được đề xuất: php - CakePHP 将 html/数据导出为 PowerPoint 格式
可可西里
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com