RelativeLayout背景未正确对齐

时间:2016-06-24 19:10:11

标签: android xml android-layout android-studio

我试图在Android Studio中为我的MainActivity设置背景,但它并没有在顶部正确对齐。

我尝试将设备从Nexus 6P更改为Nexus 5和Nexus 4,但它看起来总是一样。

这张图片可以帮助您理解问题:

Image

正如您所见,灰色三角形应该在顶部对齐,但中间有一条白线,我不知道如何移除。

这是我的代码,我非常感谢帮助解决这个问题。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="dancam.com.myapp.MainActivity">


</RelativeLayout>

我还尝试将android:layout_height设置为fill_parent,但没有改变

我使用的主题是 Light_NoTitleBar

1 个答案:

答案 0 :(得分:0)

我使用的图像在灰色三角形上方有一个透明的间隙,导致了问题。 当我在android studio中打开图像时,我能够看到差距。确保以正确的方式裁剪图像!

相关问题