RelativeLayout的子级未填充RelativeLayo

RelativeLayout的子级未填充RelativeLayo

本文介绍了RelativeLayout的子级未填充RelativeLayout的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用RelativeLayouts填充的ListView.这些RelativeLayouts的内容可以更改,因此可以分别更改其高度.在每个RelativeLayout上,我在布局的左侧都有一个垂直的小条,它与布局的高度匹配.

I have a ListView which gets populated with RelativeLayouts. The content of these RelativeLayouts can change and thus change their height respectively. On each RelativeLayout, I have a little vertical bar on the left side of the layout that matches the height of the layout.

外观与此类似-> 链接

尽管出于某些原因,我正在使用的View对象没有扩展到布局的高度.

Though for some reason, the View object that I'm using isn't expanding to the height of the layout.

我在做什么错了?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/post"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/column_post_selector"
android:orientation="horizontal" >

<!-- Status bar (THIS ISN'T FILLING TO PARENTS' HEIGHT) -->
<View
    android:id="@+id/status"
    android:layout_width="3dp"
    android:layout_height="fill_parent"
    android:layout_alignLeft="@id/post"
    android:layout_marginBottom="2dp"
    android:layout_marginTop="2dp"
    android:background="#33B5E5" />

<ImageView
    android:id="@+id/thumbnail"
    android:layout_width="80dip"
    android:layout_height="80dip"
    android:layout_toRightOf="@id/status"
    android:contentDescription="@string/empty"
    android:layout_marginRight="5dp"
    android:scaleType="fitStart" />

<!-- Title -->

<TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@id/post"
    android:layout_toRightOf="@id/thumbnail"
    android:textColor="#ffffff"
    android:textSize="14sp"
    android:typeface="sans" />
<!-- Rightend Duration -->

<TextView
    android:id="@+id/date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@id/title"
    android:layout_marginRight="5dip"
    android:gravity="right"
    android:textColor="#10bcc9"
    android:textSize="12sp"
    android:textStyle="bold" />

</RelativeLayout>

推荐答案

您将要在status中添加layout_alignParentTop="true"layout_alignParentBottom="true"-这将确保视图同时触及的RelativeLayout.

You'll want to add layout_alignParentTop="true" and layout_alignParentBottom="true" to status - this will ensure that the view touches both the top and bottom of post's RelativeLayout.

这篇关于RelativeLayout的子级未填充RelativeLayout的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 09:49