Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 屏幕背景是填充的_Android_Xml_Padding_Splash Screen - Fatal编程技术网

Android 屏幕背景是填充的

Android 屏幕背景是填充的,android,xml,padding,splash-screen,Android,Xml,Padding,Splash Screen,我为我的android应用程序创建了一个splashscreen,并设置了一个背景图像。 问题是背景图像是从屏幕边框填充的。 这是布局的xml代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:custom="http://schemas.android.com/a

我为我的android应用程序创建了一个splashscreen,并设置了一个背景图像。 问题是背景图像是从屏幕边框填充的。 这是布局的xml代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    android:paddingBottom="0dp"
    android:background="@mipmap/splashscreen_drawable"
    tools:context="quasiaffatto.myapplication.SplashScreen">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tv_logo"
    android:textColor="@color/color_white"
    android:text="App title"
    android:textSize="50sp"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:textStyle="bold"
    android:gravity="center"/>

</RelativeLayout>


为什么边界上有衬垫?我该怎么解决呢?

这真的不该发生。然而,我的第一个假设是检查该布局是否用于活动或片段。如果是一个片段,那么边距可能来自父活动,尤其是如果您是从默认模板创建的,我记得,默认模板会在默认片段之前添加一些边距空间。如果不是这样,请发布更多关于应用程序设置的信息

编辑:它可能从res文件夹中的dimen.xml中提取根元素的默认边距。尝试将根元素的边距设置为0dp。

我找到了解决方案。
问题是使用mipmap,将图像作为可绘制图像使用,效果非常好

为什么要将此可绘制地图用作mipmap?您是否尝试过将其用作常规绘图工具?@Tanis.7x我使用android studio创建了一个图像资源,它自动创建了mipmap图像资源我不确定我是否理解。Android Studio不是图像编辑器,我不知道在其中创建图像资产的任何方法。是的,这是活动的布局,我在“onCreate”方法中设置了“setContentView(R.layout.activity_splash_screen);”。但我不明白如何解决问题。这真的不重要,但是也许可以尝试将根元素的边距设置为0?但是根元素是RelativeLayout,我将所有填充值设置为0。padding是在任何包含的元素之前添加到元素内部的空间。边距是在绘制图元本身之前在图元外部添加的空间。元素的填充可以包含其背景的一部分,因为它被认为是元素可绘制区域的一部分,但它的边距不能包含,因为它是用于将其与其他元素隔开的。为了便于讨论,由于我对mipmap没有太多经验,也许可以尝试将其背景设置为纯色,看看是否仍存在此问题?