标签:android-layout android-background android
我有一个9补丁drawable(date_time).我想将此可绘制对象放置在“相对布局”内容的后面,因此所有子视图都应绘制在此图像的顶部.
这是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>
但是这种背景与所有子内容都有重叠之处.
这里显示发生了什么.
但是如果我更换
android:background="@drawable/date_time"
至
android:background="#0000FF"
一切都很好,输出是下一个:
你能解释一下我在做什么错吗?
更新:
这是我的9补丁可绘制对象.
解决方法:
就像我认为您的内容指示器不正确一样(除非您想在9补丁中引入这样的内容填充).尝试以下方法:
右侧和底部参考线确定内容应占据可绘制对象的哪一部分(或多少部分).您已将该区域设置为很小的空间,并设置了Layout的固定高度.换句话说:9-patch强制您的Layout使其子元素仅占据视图的一小部分区域(这是由于您不让Layout拉伸而受到限制).
标签:android-layout,android-background,android 来源: https://codeday.me/bug/20191120/2043218.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。