How to switch from the default ConstraintLayout to RelativeLayout in Android Studio

前端 未结 16 1016
遥遥无期
遥遥无期 2020-12-02 07:49

I have the latest android Studio (2.3 beta 3) and it seems ConstraintLayout is the default when creating a project. How can I make Android Studio use the RelativeLayout as t

相关标签:
16条回答
  • 2020-12-02 08:28

    inefficient solution:

    Create a new Layout

    1. Go to /res/layout folder in Android Studio
    2. Right click -> New -> Layout Resource files
    3. give it a name and add .xml at the end
    4. Erase the Root Element field and type 'RelativeLayout'

    0 讨论(0)
  • 2020-12-02 08:29

    just do it: in component tree right click on ConstraintLayout and select relativelayout on convert view...

    0 讨论(0)
  • 2020-12-02 08:33

    A very short way to do it is just right click on the activity_main.xml design background and select convert view then select Relativealayout. Your code in Xml Text will auto. Change. Goodluck

    0 讨论(0)
  • 2020-12-02 08:36

    The easiest way would be to select Relativelayout from the Pallete, and then use it.

    0 讨论(0)
  • 2020-12-02 08:37

    Well, I saw the answer above and it worked for me too. But, I gave it a shot, and succeded converting my current project to Relative Layout. Do as follows:

    At activity_main.xml tab, change it to text. At the top of it, you'll find the following:

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    

    Just change all before xmlns to RelativeLayout. Doing so will also change the very bottom line where you would find:

    </android.support.constraint.ConstraintLayout>
    

    to

    </RelativeLayout>
    

    Problem solved! Be happy :P

    0 讨论(0)
  • 2020-12-02 08:38

    None of these solutions worked for me...seemingly until I stumbled across this setting, see image. File > Settings > Editor > Layout Editor > Check "Prefer XML Editor"

    https://i.stack.imgur.com/9CHe7.png

    0 讨论(0)
提交回复
热议问题