2017-10-07 233 views
-6

如何删除屏幕底部的这个空白区域。我也试过android:adjustviewboundsandroid:scaletype。但仍未能删除屏幕底部的空白区域。请帮助我优化我的布局,以便从底部移除这个丑陋的空白空间。删除屏幕底部的空白Android

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

Screenshot of layout

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

这是空白部分,因为在3x190之后屏幕仍然有一些高度,您为什么使用负边距...? –

+0

我可以从你的问题中了解到,你有这三张照片,你希望它占据你的整个屏幕,不留空白。这是你想要的吗? –

+0

是的,这正是我想要的 –

回答

0

在你的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

注:不同的屏幕尺寸问题,我想在你的情况下,屏幕高度高,导致布局,在底部的空白空间。在小尺寸的屏幕上,它可能不是那样的。尝试以上操作将有助于所有屏幕尺寸

0

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

否则,你必须找出你想要的。改变图像的大小是一个不好的主意,因为它们看起来会拉长。

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

+0

我使用滚动视图,以便滚动视图内的布局不能设置为android:height =“match_parent” –

+0

我已经设置了根布局(相对布局)高度以匹配父级,但仍有空白 –

+0

False。 YOu可以将ScrollView和RelativeLayout的高度设置为'match_parent'。它是ScrollView内部的LinearLayout,它需要'wrap_content' – Zoe