首页 > 解决方案 > Scrollview 在布局底部添加了额外的空间

问题描述

1在我的活动中,滚动视图在页面底部添加了额外的空间。我也尝试在 stackoverflow 上查找,但没有任何反应。我已经尝试了一切,但没有一个对我有用..请帮助

这是我的xml代码-

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Spinner
        android:id="@+id/spinner"
        android:background="#fff"
        android:layout_marginRight="12dp"
        android:layout_marginLeft="12dp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        android:layout_width="match_parent"
        android:layout_height="45dp"/>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/spinner"
        android:scrollbars="none"
        android:overScrollMode="never"
        tools:adjustViewBounds="true"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginRight="12dp"
        android:layout_marginLeft="12dp"
        android:fillViewport="true">

    <ImageView
        android:id="@+id/image"
        android:src="@drawable/basic_01"
        android:scaleType="fitStart"
        android:focusableInTouchMode="true"
        android:layout_below="@+id/spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    </ScrollView>

</RelativeLayout>

<android.support.design.widget.NavigationView
    app:headerLayout="@layout/header"
    android:layout_width="350dp"
    android:layout_height="match_parent"
    app:menu="@menu/nav_header"
    android:id="@+id/navigation_view"
    android:layout_gravity="start">

</android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

2

标签: androidandroid-layoutscrollview

解决方案


您已经添加android:layout_marginBottom="8dp"ScrollView这就是为什么它在布局底部添加了额外的空间

android:layout_marginBottom="8dp"您的ScrollView

阅读更多关于ViewGroup.MarginLayoutParams


推荐阅读