Unwanted Margin in Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:andro开发者_如何学Pythonid="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.
Here is a screenshot:
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.
If you want to maintain the aspect ratio android:scaleType="center"
will center the image with no scaling and maintains aspect ratio. 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
Hope this helps
精彩评论