<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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"> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" tools:layout_editor_absoluteX="151dp" tools:layout_editor_absoluteY="176dp" /> </androidx.constraintlayout.widget.ConstraintLayout>
这是修改后的xml文件,该文件可以随意拖动组件进行布局。导致这种改变的是androidx.constraintlayout.widget.ConstraintLayout。
原本的似乎是LinearLayout或RelativeLayout,原本的无法随意拖动,按钮会自动对齐到左上角或者其他位置,猜测可能是设置的某种布局规则。