Android 布局中的空白白条没有任何原因

Android 布局中的空白白条没有任何原因,android,android-studio,android-layout,Android,Android Studio,Android Layout,我在布局的底部有一个很大的白色空白条,我不知道为什么。这真的是一种焦虑,我真的不喜欢它:D请帮我删除它 我的布局代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:

我在布局的底部有一个很大的白色空白条,我不知道为什么。这真的是一种焦虑,我真的不喜欢它:D请帮我删除它

我的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ededed">

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

            <android.support.design.card.MaterialCardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                app:cardBackgroundColor="@android:color/white"
                app:cardCornerRadius="10dp"
                app:cardElevation="2dp"
                app:cardPreventCornerOverlap="true">

                <ImageView
                    android:id="@+id/image"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:background="@drawable/ic_menu_camera" />
            </android.support.design.card.MaterialCardView>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/text_style_header"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/heading"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Heading...."
                    android:textAppearance="?attr/textAppearanceHeadline6"
                    android:textSize="20sp" />

                <TextView
                    android:id="@+id/description_short"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="2dp"
                    android:background="@drawable/text_style_desc"
                    android:text="Desc" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="12dp"
                    android:background="@drawable/text_style_desc"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/description"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginTop="2dp"
                        android:background="@drawable/text_style_desc"
                        android:text="text text text tex" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

在android studio的预览中没有显示任何内容,但如果我构建并运行该应用程序,它会显示工具栏。这个酒吧是从哪里来的

解决方案:此布局来自一个ViewPager布局,其中有一个空白区域用于添加点。这就是问题所在

谢谢大家!

试试这个

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ededed"
    android:fillViewport="true">

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

        <android.support.design.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            app:cardBackgroundColor="@android:color/white"
            app:cardCornerRadius="10dp"
            app:cardElevation="2dp"
            app:cardPreventCornerOverlap="true">

            <ImageView
                android:id="@+id/image"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="@drawable/dishu" />

        </android.support.design.card.MaterialCardView>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:orientation="vertical">

            <TextView
                android:id="@+id/heading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Heading...."
                android:textAppearance="?attr/textAppearanceHeadline6"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/description_short"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:background="@color/colorAccent"
                android:text="Desc" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="12dp"
                android:background="@color/colorPrimaryDark"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/description"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="2dp"
                    android:text="text text text tex" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

试试这个

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ededed"
    android:fillViewport="true">

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

        <android.support.design.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            app:cardBackgroundColor="@android:color/white"
            app:cardCornerRadius="10dp"
            app:cardElevation="2dp"
            app:cardPreventCornerOverlap="true">

            <ImageView
                android:id="@+id/image"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="@drawable/dishu" />

        </android.support.design.card.MaterialCardView>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:orientation="vertical">

            <TextView
                android:id="@+id/heading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Heading...."
                android:textAppearance="?attr/textAppearanceHeadline6"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/description_short"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:background="@color/colorAccent"
                android:text="Desc" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="12dp"
                android:background="@color/colorPrimaryDark"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/description"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="2dp"
                    android:text="text text text tex" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

为第一个线性布局而不是滚动视图提供背景色。
并在scrollview中添加fillViewport=true,为第一个线性布局而不是scrollview提供背景色。

并在scrollview中添加fillViewport=true

您正在谈论的是哪个栏?你能在截图上做标记吗?同时,您的父布局是无用的,您可以删除it@Pankaj库马尔:我的问题中有一个截图太有趣了。我可以看到屏幕截图,这就是为什么我要标记那个白色的条。它是一个碎片吗?它位于黑色导航区域和深灰色文本之间。你说的是哪个条?你能在截图上做标记吗?同时,您的父布局是无用的,您可以删除it@Pankaj库马尔:我的问题中有一个截图太有趣了。我可以看到屏幕截图,这就是为什么我要标记白色条。它是一个碎片吗?它位于黑色导航区域和深灰色文本之间。条仍然在那里,但你是对的。最好给主布局上色。条仍然在那里,但你是对的,最好给主布局涂上颜色酒吧仍然是there@OliverWeidner检查更新的答案我已经做了一些更改仍然在那里,也许你必须知道这个布局属于一个viewpageractivity@OliverWeidner请与问题分享您的活动布局问题在您的活动布局中这里是问题@Nilesh Rathod您昨天也帮助了我!比你多一倍!酒吧还在营业there@OliverWeidner检查更新的答案我已经做了一些更改仍然在那里,也许你必须知道这个布局属于一个viewpageractivity@OliverWeidner请与问题分享您的活动布局问题在您的活动布局中这里是问题@Nilesh Rathod您昨天也帮助了我!比你多一倍!