13

RelativeLayouts が取り込まれる ListView があります。これらの RelativeLayouts のコンテンツは変更できるため、それぞれの高さが変更されます。各 RelativeLayout では、レイアウトの左側に、レイアウトの高さに一致する小さな垂直バーがあります。

これに似た外観です - >リンク

なんらかの理由で、使用している View オブジェクトがレイアウトの高さまで拡大されません。

私は何を間違っていますか?

<?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>
4

8 に答える 8

0

onLayout無効なビューのときにレイアウトを手動で設定して修正しました:

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    int rootMarginRight = ((MarginLayoutParams)root.getLayoutParams()).rightMargin;
    int paddingRight = root.getPaddingRight() + rootMarginRight;

    //invalid view
    actionsContainer.layout(
            right - actions.getWidth() - paddingRight,
            0,
            right - paddingRight,
            getHeight()
    );
}
于 2014-07-31T13:56:01.437 に答える
0

ちなみに意味のない同じ厄介な問題がありました。最終的に私にとってうまくいったのは、android:layout_heightin RelativeLayout タグをfill_parentこのように変更することでした

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
  ...

お役に立てれば

于 2013-05-25T09:12:07.817 に答える
-1

私の問題は次の行でした

android:fitsSystemWindows="true" <-- In the parent view

除去された。再度追加したところ、現在は正常に動作しています。

于 2016-03-04T23:15:07.497 に答える