[英]View not taking the same height as parent RelativeLayout
我正在尝试实现下图右侧的布局。 我现在得到的是在左边。
这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/garment_grid_item_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gridview_image_placeholder"
android:contentDescription="@string/blank"
android:scaleType="centerCrop"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/garment_grid_item_on_loan"
android:src="@drawable/icon_borrowed"
android:contentDescription="@string/blank"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:visibility="gone"
/>
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/item_border"
/>
</RelativeLayout>
@drawable/item_border
(石灰绿色只是为了突出透明区域):
RelativeLayout
用作GridView
的项目模板。 garment_grid_item_image
正在代码中填充。 garment_grid_item_on_loan
是garment_grid_item_on_loan
的紫色三角形,其可见性由代码控制。
底部的View
使用9补丁,这是我遇到的问题。 我希望它和父级RelativeLayout
一样高,但是match_parent
或fill_parent
都不能工作。 我该怎么做才能使其正常工作?
我刚刚尝试过使用一些相似的图像进行布局,并且在Activity中设置为根元素时,效果很好。
这可能与您的RelativeLayout具有wrap_content的大小有关,而子视图未指定要包装的大小。 尝试指定固定大小,只是看问题是否消失,然后再从那里消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.