繁体   English   中英

从Android屏幕底部删除空白

[英]Remove white space from the bottom of screen Android

我如何删除屏幕底部的这个空白区域。 我也试过android:adjustviewboundsandroid:scaletype 但是还是没能去掉屏幕底部的空白。 请帮我优化我的布局,以便我可以从底部删除那个丑陋的空白。

这是我的布局屏幕的屏幕截图。

布局截图

这是我的布局的 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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM