从屏幕底部移除白色 space Android

Remove white space from the bottom of screen Android

如何删除屏幕底部的白色 space。我也试过 android:adjustviewboundsandroid:scaletype。但是还是没能去掉屏幕下方的白色space。请帮助我优化我的布局,以便我可以从底部删除丑陋的白色 space。

下面是我的布局屏幕的屏幕截图。

这是我的 XML 布局代码。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content"
android:layout_width="match_parent"
tools:context="com.example.zohai.v360.Fragments.Home">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginTop="-15dp">
            <ImageView
                android:id="@+id/intro"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                android:adjustViewBounds="true"
                android:background="@drawable/intro"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginTop="-15dp"
            >

            <ImageView
                android:id="@+id/photog"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/photographers"
                android:adjustViewBounds="true"
                android:scaleType="fitXY"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginTop="-14dp">
            <ImageView
                android:id="@+id/model"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/model_bg"
                android:adjustViewBounds="true"
                android:scaleType="fitXY"
                />

        </LinearLayout>

    </LinearLayout>

</ScrollView>

</RelativeLayout>

您的布局高度设置为 wrap_content。空白在那里是因为您没有足够的内容大小来完全填满屏幕。如果将高度设置为 match_parent,则可以通过在根视图上设置 android:background 来使空格消失。

否则你必须在那里找到你想要的东西。更改图像的大小不是一个好主意,因为它们看起来会被拉伸。

并且由于 android 是一个大平台,您会发现在某些设备上没有空白,而在其他设备上空白会更大。不要将图像的大小设置为固定大小。

在您提到的 xml 代码中

android:layout_height="190dp"

这通常对 android:scaletype

没有帮助

约束布局带权重的线性布局将 3 个线性布局分配到屏幕高度。像这样,

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_marginTop="-15dp">
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_marginTop="-15dp">
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_marginTop="-15dp">

然后用android:scaletype来拟合LinearLayout

注意:不同的屏幕尺寸很重要,我认为在你的情况下屏幕高度很高,这导致布局底部有空白 space。在小尺寸屏幕上可能不是这样。尝试执行以上操作将有助于所有屏幕尺寸