相对布局在 Android Studio 中不起作用总是在设计视图中显示约束布局
Relative Layout didn't Work in Android Studio Always Shows Constraint Layout in Design View
在 android 工作室更新后,相关布局不起作用 android 工作室总是在设计视图中显示约束布局。
即使我选择了相对布局,但它总是要求限制小部件。
我已经尝试在不同的论坛上进行在线搜索,但没有找到解决方案。
在这里,我使用了2个编辑文本,如图所示我想要相对布局,因为它更方便,但现在不起作用。
有人可以帮忙找出我哪里做错了吗?
这是设计视图
design view
这里是XML的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<EditText
android:id="@+id/txt_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="enter email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/txt_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_email"
android:hint="enter password"
android:inputType="textPassword" />
<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_password"
android:text="Submit" />
</RelativeLayout>
[1]: https://i.stack.imgur.com/zlpik.png
这些约束具有与下面的或 start_of 相同的功能,relative_layout 具有...但是
我建议您更换
android:layout_below
对于这个或者或者如果你不需要也可以像这样限制在父级中:
app:layout_constraintTop_toBottomOf="parent" or "@id/your_component_id
但请记住,只有当所有子项都包裹在 constraint_layout 中时,这才有效。并将您的相对布局包装在 constraint_layout.
内
在 android 工作室更新后,相关布局不起作用 android 工作室总是在设计视图中显示约束布局。
即使我选择了相对布局,但它总是要求限制小部件。
我已经尝试在不同的论坛上进行在线搜索,但没有找到解决方案。
在这里,我使用了2个编辑文本,如图所示我想要相对布局,因为它更方便,但现在不起作用。
有人可以帮忙找出我哪里做错了吗?
这是设计视图 design view
这里是XML的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<EditText
android:id="@+id/txt_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="enter email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/txt_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_email"
android:hint="enter password"
android:inputType="textPassword" />
<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_password"
android:text="Submit" />
</RelativeLayout>
[1]: https://i.stack.imgur.com/zlpik.png
这些约束具有与下面的或 start_of 相同的功能,relative_layout 具有...但是
我建议您更换
android:layout_below
对于这个或者或者如果你不需要也可以像这样限制在父级中:
app:layout_constraintTop_toBottomOf="parent" or "@id/your_component_id
但请记住,只有当所有子项都包裹在 constraint_layout 中时,这才有效。并将您的相对布局包装在 constraint_layout.
内