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

前端 未结 16 1014
遥遥无期
遥遥无期 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:21

    I am answering this for android studio 2.3.1. One of the easiest ways to set RelativeLayout as default layout is going to text mode and editing the XML file as follows:

    Change this line:

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

    To

    <android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    And do check your ending tag changes to this:

    </android.widget.RelativeLayout>

    Also (optionally) go ahead and delete this line if it's being shown in grey:

    xmlns:app="http://schemas.android.com/apk/res-auto"

    Edit:

    This is an optional change to make in project, I came across this tip while going through Udacity's Android Developer Course

    If the constraint layout is not needed in the project remove the following dependency from build.gradle by deleting this line and then doing gradle sync:

        compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    
    0 讨论(0)
  • 2020-12-02 08:21

    TO CHANGE ConstraintLayout to RelativeLayout: This will work in Android studio 3.0.1

    Change->

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

    into

    <android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    

    and->

    </android.support.constraint.ConstraintLayout>
    

    nto

    </android.widget.RelativeLayout>
    
    0 讨论(0)
  • 2020-12-02 08:22

    Android 3.0

    In activity_main.xml

    Replace in this tag i.e <android.support.constraint.ConstraintLayout>

    android.support.constraint.ConstraintLayout

    with

    RelativeLayout

    0 讨论(0)
  • 2020-12-02 08:25
    1. Right click on ConstraintLayout.
    2. Select convertview.
    3. select RelativeLayout

    For more clarity refer below image

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

    Just right click on the ConstrainLayout and select the "convert view" and then "RelativeLayout":

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

    Try this. It's helped me to change from ConstraintLayout to RelativeLayout.

    Try this... That helped me to change from ConstraintLayout to RelativeLayout

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