简体   繁体   中英

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. 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.

I figured out a solution. I added " android:launchMode="singleTop" " to the relativelayout and it solved the problem!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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