简体   繁体   English

为什么我的relativelayout不填满屏幕? - android

[英]Why isn't my relativelayout filling the screen? - android

I am struggling to figure out why my relativelayout screen is not filling the entire screen. 我正在努力弄清楚为什么我的relativelayout屏幕没有填满整个屏幕。 I have tried a number of things, but the horizontal space of the screen never appears filled. 我尝试了很多东西,但是屏幕的水平空间永远不会出现。 What am i doing wrong? 我究竟做错了什么?

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

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:textSize="12sp"
        android:textColor="#454545"
        android:gravity="center_horizontal"
        android:layout_alignParentBottom="true"
        android:text="MyAppName"
        />

</RelativeLayout>

The old name is deprecated, change the values to this.. 旧名称已弃用,请将值更改为此值。

android:layout_width="match_parent"
android:layout_height="match_parent"

Adding singletop will replace the last instance of your activity so if that solved your problem maybe you are instantiating your activity more than once somewhere, and that is why didnt worked before. 添加singletop将替换你活动的最后一个实例,所以如果这解决了你的问题,你可能会在某个地方多次实例化你的活动,这就是为什么之前没有工作的原因。

I figured out a solution. 我想出了一个解决方案。 I added " android:launchMode="singleTop" " to the relativelayout and it solved the problem! 我将“android:launchMode =”singleTop“”添加到relativelayout,它解决了问题!

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

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