为什么 android studio designer 不为相对布局工作
Why android studio designer is not working for relative layout
不会为相对布局自动生成 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">
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</RelativeLayout
我该怎么办?
是的,如果你拉动ConstraintLayout上的组件,它会猜测你想要什么并为你设置属性。
对于 RelativeLayout,您需要使属性视图可见并从那里进行编辑。您需要像这样编辑参数:
android:layout_below="@id/name"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/times"
我遇到了同样的问题,我尝试了以下步骤;
- 点击磁铁图标(眼睛图标旁边,左上角,调色板菜单旁边),这样它就不会被划掉:这会打开自动连接。
- 这将帮助您将按钮移动到您想要放置的位置。
试试看然后告诉我。
不会为相对布局自动生成 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">
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</RelativeLayout
我该怎么办?
是的,如果你拉动ConstraintLayout上的组件,它会猜测你想要什么并为你设置属性。 对于 RelativeLayout,您需要使属性视图可见并从那里进行编辑。您需要像这样编辑参数:
android:layout_below="@id/name"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/times"
我遇到了同样的问题,我尝试了以下步骤;
- 点击磁铁图标(眼睛图标旁边,左上角,调色板菜单旁边),这样它就不会被划掉:这会打开自动连接。
- 这将帮助您将按钮移动到您想要放置的位置。
试试看然后告诉我。