android - 无法在 Android Studio 中为 RelativeLayout 移动任何元素
问题描述
我正在尝试将一些按钮/文本视图或任何其他组件添加到我的相对布局中。除了左上角,我不能把它们放在任何地方。但是,如果我编辑 XML 代码,它可以正常工作。
我已经将布局更改为 relativeLayout 但仍然没有运气。(安卓工作室 3.3)
我的布局 xml 是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</RelativeLayout>
我希望将这些按钮/文本视图相对于彼此移动,但它们只是停留在左上角。
解决方案
视图编辑器顶部有一个磁性按钮,称为(开/关自动连接)。如果你改变它,你可以在相对布局中移动视图。
推荐阅读
- ubuntu - nvidia-smi 命令是做什么的?
- r - 自开始学习周以来的R重新编码天数
- python - 如何使用 CPU 运行一个进程并使用 GPU 运行另一个进程?
- graph - 从驱动器 ID 检索 Microsoft Graph 描述
- reactjs - 无法单击 SVG 内的项目
- django - Django:在一个查询中对 3 个模型使用 select_related / prefetch_related
- bigdata - 如何在 Flink 中使用本地执行模式执行批处理 sql?
- javascript - 我想在同一水平面上放置两个网格,每个网格宽度为 50%
- javascript - 如何将 Jsonplaceholder 数据渲染到 HTML 表中?
- php - 无法在 Docker 中安装 PHP 扩展