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

时间:2017-05-14 15:31:46

标签: android

当我在Android studio中创建一个新项目并选择一个空白活动时,会附加一个默认的Constraint Layout。

我正在尝试使用网格布局跟踪一些在线教程,但由于约束布局,它无法按预期工作。

本教程已有几年了,所以我猜测约束布局是更新的一部分。

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

以下是默认的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>

1 个答案:

答案 0 :(得分:2)

您可以删除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>