Android   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android LinearLayout:未显示正确的高度大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个带有白色背景的LinearLayout,里面装满了一堆LinearLayouts和RelativeLayouts.我试图将父布局设置为具有最小高度,但它似乎仍然包含在内容中.

这是现在的样子.空白区域的最小高度应该大于现在的最小高度.

以下是我认为xml的相关部分:

<ScrollView xmlns:android="http://scheR_698_11845@as.android.com/apk/res/android"
    android:id="@+id/contactViewScrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:BACkground="#ABABAB" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="300dip"
        android:BACkground="#FFFFFF"
        android:orientation="vertical" >

        <RelativeLayout
            android:id="@+id/contactHeader"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:BACkground="#EDEDED"
            android:paddingLeft="10dp" >

            <TextView
                android:id="@+id/fullName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="175dip"
                android:paddingTop="5dp"
                android:textSize="18sp" />

            <View
                android:layout_width="1dp"
                android:layout_height="90dp"
                android:layout_toLeftOf="@+id/image"
                android:BACkground="#000000" />

            <ImageView
                android:id="@+id/image"
                android:layout_width="90dp"
                android:layout_height="90dp"
                android:layout_alignParen@R_696_10296@ht="true"
                android:BACkground="#D6D6D6"
                android:contentDescription="@String/contact_image_description"
                android:scaleType="centerCrop" />
        </RelativeLayout>

        <View
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:BACkground="#000000" />

        <LinearLayout
            android:id="@+id/mobile"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="10dp" >

            <TextView
                android:id="@+id/mobilePhoneheading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="15dp"
                android:text="@String/mobile_phone"
                android:textColor="#787878" />

            <TextView
                android:id="@+id/mobilePhone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingTop="2dp"
                android:textSize="18sp" />
        </LinearLayout>

…以及许多其他LinearLayouts,都以编程方式设置为’GONE’.

有人可以建议修复吗?我无法弄清楚为什么白色部分占用的空间如此之小.

解决方法:

// try this
<ScrollView xmlns:android="http://scheR_698_11845@as.android.com/apk/res/android"
    android:id="@+id/contactViewScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:BACkground="#ABABAB" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:BACkground="#FFFFFF"
            android:orientation="vertical" >

            <RelativeLayout
                android:id="@+id/contactHeader"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:BACkground="#EDEDED"
                android:paddingLeft="10dp" >

                <TextView
                    android:id="@+id/fullName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="175dp"
                    android:paddingTop="5dp"
                    android:textSize="18sp" />

                <View
                    android:layout_width="1dp"
                    android:layout_height="90dp"
                    android:layout_toLeftOf="@id/image"
                    android:BACkground="#000000" />

                <ImageView
                    android:id="@+id/image"
                    android:layout_width="90dp"
                    android:layout_height="90dp"
                    android:layout_alignParen@R_696_10296@ht="true"
                    android:BACkground="#D6D6D6"
                    android:contentDescription="contact_image_description"
                    android:scaleType="centerCrop" />
            </RelativeLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:BACkground="#000000" />

            <LinearLayout
                android:id="@+id/mobile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="10dp" >

                <TextView
                    android:id="@+id/mobilePhoneheading"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingTop="15dp"
                    android:text="mobile_phone"
                    android:textColor="#787878" />

                <TextView
                    android:id="@+id/mobilePhone"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingBottom="10dp"
                    android:paddingTop="2dp"
                    android:textSize="18sp" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

大佬总结

以上是大佬教程为你收集整理的Android LinearLayout:未显示正确的高度全部内容,希望文章能够帮你解决Android LinearLayout:未显示正确的高度所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: