Android layout 在Android Studio预览版中,容器扩展到了更大的范围

Android layout 在Android Studio预览版中,容器扩展到了更大的范围,android-layout,android-studio,Android Layout,Android Studio,每当我在设计器界面上添加一个新的容器视图,并将layout:width和layout:height设置为wrap\u content,容器视图的大小就会超出其应有的大小,如下所示 我应该如何解决此问题 content\u main.xml的代码片段 编辑:可能与上面的图像有点不同,但仍然是相同的问题。 使用 android:layout\u width=“匹配父项” android:layout\u height=“match\u parent” 胡乱猜测,但尝试使用scrollview

每当我在设计器界面上添加一个新的容器视图,并将
layout:width
layout:height
设置为
wrap\u content
,容器视图的大小就会超出其应有的大小,如下所示

我应该如何解决此问题

content\u main.xml的代码片段

编辑:可能与上面的图像有点不同,但仍然是相同的问题。


使用

android:layout\u width=“匹配父项” android:layout\u height=“match\u parent”


胡乱猜测,但尝试使用scrollview而不是relativelayout

或者在布局中,以便在填充listview且不拉伸时保持相同的大小

这是因为你的
app:layout\u behavior=”“

尝试更改或删除它,您的容器大小不会超过。

尝试将
warp\u内容更改为
match\u parent

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listView"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:padding="0dp" />

这没什么错


预览仅显示使用
简单的两行列表项的预览。它被拉伸是因为您将其设置为
wrap content
,因此
ListView
实际上会比屏幕长,如果其中有超过8个项目(至少在该设备的预览中,可能在Nexus 6的预览中,您会看到10个项目).

您的顶部菜单栏正在降低您的子div,或者您的软导航键正在“浮动”

首先,尝试隐藏状态栏(顶部)

第二,在Android虚拟设备管理器中尝试一个没有虚拟按钮栏的新设备,比如Galaxy s7,或者尝试隐藏它。

我认为这是因为listview需要先填充列表视图项,然后才能计算其高度和宽度。因此,如果没有测量的高度和宽度,它就无法按照您的要求包装内容。我认为除了用xml格式的示例内容填充listview之外,没有什么好办法可以解决这个问题。发布您的xml代码片段,而不是在图像中提供。设置
app:layout\u behavior=“”
将listview上移到actionbar的上方和后面。这是它现在的样子。不幸的是,将android:layout_width/height
更改为
match_parent
并没有改变预览行为。如果这与html类似,那么如果匹配parent但将padding top和padding bottom设置为0dp会发生什么情况?@PaulTotzke仍然存在相同的问题。我在学习一个教程。在本教程中,当作者将所有填充设置为0时,listview占据了整个屏幕。但就我而言,这并没有发生。
<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listView"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:padding="0dp" />