將Android Studio默認佈局ConstraintLayout切換成LinearLayout

轉自:https://blog.csdn.net/rikkatheworld/article/details/77075396

至於我對扁平化佈局ConstraintLayout使用不是很熟悉,而Android Studio的默認佈局就是ConstraintLayout,所以想將其默認佈局改爲LinearLayout

找到安裝AS路徑 
Android Studio\plugins\android\lib\templates\activities\common\root\res\layout 
下面的simple.xml.ftl文件用記事本打開 
上面顯示爲扁平化佈局的默認代碼,要將其修改爲線性佈局 
將所有代碼改成:

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:app="http://schemas.android.com/apk/res-auto"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent">  

    <TextView  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="Hello World!"  
    />  


</LinearLayout> 

重開AS即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章