2017-05-14 105 views
0

當我在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

回答

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>