Android 为什么线性布局在我的AVD中不可见?
我试图理解为什么我的线性布局没有出现在AVD中,但没有任何效果。。请查看我的快照以了解更多详细信息,如果我有任何错误,请告诉我。我删除了这个程序中相对布局的一部分,以便调试一个不那么凌乱的问题代码Android 为什么线性布局在我的AVD中不可见?,android,Android,我试图理解为什么我的线性布局没有出现在AVD中,但没有任何效果。。请查看我的快照以了解更多详细信息,如果我有任何错误,请告诉我。我删除了这个程序中相对布局的一部分,以便调试一个不那么凌乱的问题代码 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schem
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="233dp"
android:background="@android:color/holo_blue_bright"
android:orientation="horizontal"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="1dp">
<Button
android:id="@+id/button_small"
android:layout_width="98dp"
android:layout_height="wrap_content"
android:text="Small" />
<Button
android:id="@+id/button_big"
android:layout_width="164dp"
android:layout_height="match_parent"
android:text="Big" />
</LinearLayout>
向
线性布局添加约束,因为它们被忽略
删除
tools:ignore="MissingConstraints"
要查看缺少的约束,
每个视图至少需要使用两个约束(一个用于垂直轴,一个用于水平轴)进行约束。在代码中添加/替换此约束:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="233dp"
android:background="@android:color/holo_blue_bright"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/other_layout"
tools:ignore="MissingConstraints">
<Button
android:id="@+id/button_small"
android:layout_width="98dp"
android:layout_height="wrap_content"
android:text="Small" />
<Button
android:id="@+id/button_big"
android:layout_width="164dp"
android:layout_height="match_parent"
android:text="Big" />
</LinearLayout>
在您的代码中,您没有给出约束值,因此,每当您尝试在模拟器或设备中运行代码时,布局都会自动换行到0,0。嘿,我尝试了您的代码,但是app:layout\u constraintBottom\u toBottomOf=“@+id/other\u layout”
显示错误,而线性布局仍然没有出现在AVD中?你认为我必须安装一些东西才能让它工作吗?嘿。我将代码更改为
,但仍然无法工作dunno问题出在哪里移除底部约束,一切都应正常工作,确保视图(在linearLayout下)未覆盖线性布局,您可以尝试隐藏它以进行测试。相对布局的视图覆盖了线性布局是的