Android 相对背景可绘制重叠内容
我有一个9补丁的可绘制(日期\时间)。我想把这个可绘制的放在相对布局内容的后面,所以所有的子视图都应该绘制在这个图像的上面。 以下是xml布局:Android 相对背景可绘制重叠内容,android,android-layout,android-background,Android,Android Layout,Android Background,我有一个9补丁的可绘制(日期\时间)。我想把这个可绘制的放在相对布局内容的后面,所以所有的子视图都应该绘制在这个图像的上面。 以下是xml布局: <RelativeLayout android:layout_width="wrap_content" android:layout_height="23dp" android:layout_below="@id/tv_map_address" and
<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>
到
一切正常,输出结果如下:
你能解释一下我做错了什么吗
更新:
这是我的9-patch可拉丝
正如我所认为的,您的内容指示器是不正确的(除非您想在9-patch中引入这样的内容填充)。请尝试以下方法:
右侧和底部参考线,确定内容应占据
可绘制部分的哪个部分(或多少)。您已经将该区域设置为非常小的空间,并设置了布局的固定高度。换句话说:9-patch强迫您的布局
让其子项只占据您视图的一小部分(这受到您不允许布局
拉伸的限制)。发布您的9-patch可绘制,内容指示器可能不正确。@blipinsk我添加了可绘制。如果你需要测试,我也可以上传到一些imagehost上。是的。你完全正确。最后,我终于明白了这个9补丁魔术是如何实际工作的。谢谢。太棒了,很高兴我能帮忙:)
android:background="@drawable/date_time"
android:background="#0000FF"