简体   繁体   中英

RelativeLayout won't fill the whole screen

I have three RelativeLauouts in a LinearLayout and I can't make it fill the whole screen on my emulator?? What is the problem?

Here is my xml :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.5">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/letteord"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/letteord"
        android:scaleType="centerCrop"
        android:layout_alignParentEnd="true" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Let"
        android:id="@+id/letteOrdbutton"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:textSize="50dp"
        android:background="#a4000000"
        android:textColor="#FFFFFF" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.5">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/normaleord"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/normaleord"
        android:scaleType="centerCrop"
        android:layout_alignParentEnd="true" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Normal"
        android:id="@+id/normaleOrdbutton"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:textColor="#FFFFFF"
        android:background="#a4000000"
        android:textSize="50dp" />
</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.5">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/svaereord"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/svaereord"
        android:scaleType="centerCrop"
        android:layout_alignParentEnd="true" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Svær"
        android:id="@+id/svaereOrdbutton"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:textSize="50dp"
        android:textColor="#FFFFFF"
        android:background="#a4000000" />
</RelativeLayout>
</LinearLayout>

I have tried changing the layout with and height but it still won't fill the whole screen as you can see on this screenshot:

在此处输入图片说明

Well, I see no paddings or margins in the code above. Is this just a portion of your code in your xml file? Check your main activity layout to see if there is any padding or margins. Delete them if there is and it should work fine.

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