如何删除空白活动的默认约束布局?

问题描述:

当我在Android Studio中创建一个新项目并选择一个空白活动时,会附加一个默认的约束布局。如何删除空白活动的默认约束布局?

我正在尝试使用网格布局遵循一些在线教程,但由于约束布局,它不像预期的那样工作。

该教程是一个几岁,所以我猜约束布局是更新的一部分。

是否有可能摆脱这种约束布局?

下面是默认XML:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.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="com.user1.gridlayoutApp.MainActivity" 
tools:layout_editor_absoluteY="81dp" 
tools:layout_editor_absoluteX="0dp"> 

</android.support.constraint.ConstraintLayout> 
+0

只是删除布局和添加自己的 –

+1

转到文本模式布局,选择ConstraintLayout root并擦除它。插入你自己的。 –

+0

@MithunSarkerShuvro嗨,我已经尝试右键单击组件树中的布局,但它不会让我删除它出于某种原因 – user2911539

你可以删除ConstraintLayout标签和添加的LinearLayout:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    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:orientation="vertical"> 
</LinearLayout>