简体   繁体   English

布局中的多余边距

[英]Unwanted Margin in Layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainRlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<ImageView 
    android:src="@drawable/moflow_main_screen"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true" />

<TextView 
    android:id="@+id/txtMoflow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_above="@+id/initCapsText"
    android:text="MoFlow"
    android:textSize="40sp"
    android:textColor="#FA3248"
    android:typeface="serif" />
<TextView
    android:id="@+id/initCapsText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_above="@+id/startBtn"
    android:text="TESTING"
    android:textSize="16sp"
    android:textColor="#FFFFFF" />
<Button
        android:id="@+id/startBtn" 
        android:layout_width="120dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:layout_above="@+id/manageBtn"
        android:text="Start Testing" />
<Button
        android:id="@+id/manageBtn" 
        android:layout_width="120dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Management" />
<Button
        android:id="@+id/optionsBtn" 
        android:layout_width="120dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/manageBtn"
        android:text="Options" />
<Button
        android:id="@+id/aboutBtn" 
        android:layout_width="120dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/optionsBtn"
        android:text="About" />
<Button
        android:id="@+id/quitBtn" 
        android:layout_width="120dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/aboutBtn"
        android:text="Quit" />
</RelativeLayout>

I want the image view picture to go all the way down to the screen, but there is a margin at the bottom and I don't know where it's coming from. 我希望图像查看图片一直向下到屏幕,但是底部有一个空白,我不知道它来自哪里。 I thought it might be the image dimensions, but even setting to 1000x1000 pixels doesn't do anything to get rid of the margins, neither does setting alignParentBottom. 我以为可能是图像尺寸,但是即使将其设置为1000x1000像素也无法消除空白,设置alignParentBottom也是如此。

Here is a screenshot: 这是屏幕截图: marginProblem

Does the image you are using match the dimensions of the screen? 您使用的图像是否与屏幕尺寸匹配?

If not: 如果不:

Try setting android:scaleType="fitXY" on the ImageView - This will scale the image to fit the screen but will not retain the images original aspect ratio. 尝试在ImageView上设置android:scaleType="fitXY" -这将缩放图像以适合屏幕,但不会保留图像的原始宽高比。

If you want to maintain the aspect ratio android:scaleType="center" will center the image with no scaling and maintains aspect ratio. 如果要保持宽高比,则android:scaleType="center"将使图像居中而不缩放,并保持宽高比。 However it will crop the image if it is larger than the screen, or it will not fill the screen if it is too small. 但是,如果图像比屏幕大,则会裁切图像;如果图像太小,则不会填满屏幕。

For other scale types, check out http://developer.android.com/reference/android/widget/ImageView.ScaleType.html 对于其他比例尺类型,请查看http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

Hope this helps 希望这可以帮助

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

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