【问题标题】:RelativeLayout won't fill the whole screenRelativeLayout 不会填满整个屏幕
【发布时间】:2016-01-09 20:25:10
【问题描述】:

我在一个LinearLayout 中有三个RelativeLauouts,但我无法让它填满我的模拟器上的整个屏幕??问题是什么?

这是我的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>

我已尝试使用 和 高度更改布局,但它仍然无法填满整个屏幕,正如您在此屏幕截图中看到的那样:

【问题讨论】:

  • 这是一个片段还是一个活动?你的活动布局中有填充吗?
  • 这是一个没有填充的片段
  • 但主活动布局确实有填充
  • 这就是你的问题。从您的活动中删除填充。
  • 是的,这是问题所在,现在可以了,谢谢!!

标签: android android-layout android-linearlayout android-relativelayout


【解决方案1】:

好吧,我在上面的代码中没有看到任何填充或边距。这只是xml 文件中代码的一部分吗?检查您的主要活动布局以查看是否有任何填充或边距。如果有,请删除它们,它应该可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-20
    相关资源
    最近更新 更多