gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 22:04:08 27 4
gpt4 key购买 nike

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

<RelativeLayout
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">

<ImageView
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"/>

<TextView
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"/>

<ImageView
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"/>

<TextView
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"/>

</RelativeLayout>

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

Overlapping content

但是如果我替换

android:background="@drawable/date_time"

android:background="#0000FF"

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

enter image description here

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

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

enter image description here

最佳答案

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

9-patch

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

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com