layout_height总是包装内容

Flá*_*ria 4 android android-layout

这只是一个简单的问题:

我有一个布局文件,它作为ListView中的项目呈现.我将RelativeLayout的高度设置为100dp,但它不起作用,它总是包装内容,无论我使用哪种布局.如何在不进行包装的情况下将固定值设置为布局高度?

谢谢您的帮助.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="100dp"> <!-- this attribute seems to be ignored -->

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:orientation="horizontal"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_centerHorizontal="true">

        <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="@dimen/progressbar_small"
                 android:layout_height="@dimen/progressbar_small"
                 android:layout_gravity="center_vertical" />

        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="5dp"
                 android:text="@string/loading"
                 android:layout_gravity="center_vertical"
                 style="@style/ListItemSubtext" />

     </LinearLayout>
 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

not*_*ing 6

这样做:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minHeight="100dip">
Run Code Online (Sandbox Code Playgroud)