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

constraint layout in android tutorials point
when to use constraint layout
android-relativelayout align right
constraint layout vs relative layout
android constraint layout responsive design
android:layout_below
changing layout in android studio
how to change position of button in android studio

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 the default layout element for new projects ?

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

Build a Responsive UI with ConstraintLayout, How do you switch from the default ConstraintLayout to RelativeLayout in Android Studio? Ad by DuckDuckGo. Questions: I have the latest android Studio (2.3 beta 3) and it seems ConstraintLayout is the default when creating a project. How can I switch it to RelativeLayout ? Answers: Well, I saw the answer above and it worked for me too.

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'

Relative Layout, RelativeLayout is a view group that displays child views in relative animate layout updates · Animate layout changes using a transition Positioning Views; Example support, you should instead build your layout with ConstraintLayout. By default, all child views are drawn at the top-left of the layout,  Just replace Constrain Layout by Relative Layout. In simple word just write Relative Layout in place of android.support.constraint.ConstraintLayout. Your final code

Android studio 3.0

step0:

Close android studio

step1:

Goto C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout\

step2:

Backup simple.xml.ftl

step3:

Change simple.xml.ftl to code below and save :

<RelativeLayout 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="${packageName}.${activityClass}">


<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginStart="12dp"
    android:layout_marginTop="21dp"
    android:text="don't forget to click useful if this helps. this is my first post at stackoverflow!"
    android:textSize="20sp"
    />

</RelativeLayout>

I can not find the Relative Layout. And I think that is the only was to , And I think that is the only was to change the background color. You can find it in palette>layouts in Android Studio . The default layout in the new version is called ConstraintLayout and is , in my opinion , much better than  We're updating Build a Simple Android App to use ConstraintLayout, but you can just rebuild the view in the Design layout using a RelativeLayout, or edit the XML directly. Here's the completed XML file if you want to just copy/paste this:

for android studio 3.1

If you want your default android studio change, just follow bellow steps:

first

go to C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout

i.e. the file directory where you have installed android studio.

then

copy simple.xml from another place just for backup

after that

open simple.xml file and replace it's code as bellow

<?xml version="1.0" encoding="utf-8"
<RelativeLayout 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="${packageName}.${activityClass}">



</RelativeLayout>

but if you just want to change this project layout, just go to activity_main.xml and then go to text and post upper code to there

ConstraintLayout Tutorial for Android: Getting Started , RelativeLayout is expensive because it always does two measure passes. ConstraintLayout , which is now the default layout in Android Studio, gives As you develop the app UI, you will switch back and forth between a  RelativeLayout lets child views specify their position relative to the parent view or to each other (specified by ID). So you can align two elements by right border, or make one below another, centered in the screen, centered left, and so on. By default, all child views are drawn at the top-left of the layout, so you must define the position of

I think u want to change the default settings of android studio. Whenever a layout or Activity in created u want to create "RelativeLayout" by default. In that case, flow the step below

  1. click any folder u used to create layout or Activity
  2. then "New>> Edit File Templates
  3. then go to "Other" tab
  4. select "LayoutResourceFile.xml" and "LayoutResourceFile_vertical.xml"
  5. change "${ROOT_TAG}" to "RelativeLayout"
  6. click "Ok"

you are done

Relative Layout is Dead. Meet Constraint Layout, Building an Android UI that looks great on multiple devices can be frustrating. What if we made it easy? Why Constraint Layout instead of other Layouts? For example, let's put a TextView's top to be to the bottom of a blue square view. <​View All centered views actually have a bias of 0.5 by default. Differences between ConstraintLayout and RelativeLayout is the most common question asked in an interview with the experienced android developer. The top differences are explained in this tutorial. Flat view hierarchy – no nested view groups

Layouts in Android Studio - Which ones should we use?, How to use a Constraint Layout in Android Studio? with a relative layout [​Android Studio version 2.3 and above has the default layout set to  The Video Will Show How To Change Constraint Layout To Linear Layout In Android Studio 2.3 And How To Solve Class Not Found Issue In Android Studio.

Android Studio 2.3.3 uses ConstraintLayout for an empty project by , Android Studio 2.3.3 uses ConstraintLayout for an empty project by default · Android Studio 2.3.3. Following the instructions, I get a default activity layout activity_quiz.xml which uses ConstraintLayout instead of RelativeLayout. Yea, the new project templates sometimes change in Android Studio. Constraint Layout Tutorial With Example In Android Studio [Step by Step] Constraint Layout is a ViewGroup (i.e. a view that holds other views) which allows you to create large and complex layouts with a flat view hierarchy, and also allows you to position and size widgets in a very flexible way.

Open your layout in Android Studio and click the Design tab at the bottom of the editor window. In the Component Tree window, right-click the layout and click Convert layout to ConstraintLayout. Create a new layout To start a new constraint layout file, follow these steps:

Comments
  • This answer doesn't address the question, which is asking how to change the default layout when creating a project.
  • This answer changes the layout for "current" project the question is for changing the default layout , if you rarely use a constraint layout then it is waste of time to change the layout on each project you create and therefor you should change the default file template to the code you like to start with.
  • what relate between this answer and question?
  • This worked for me. This is the only answer that actually changes the default; all the other answers only change it for the current project and it goes back to constraintLayout the next time I start a new Android Studio project.
  • Mac users: See stackoverflow.com/questions/23537065/… for the location of the plugin folder on the mac.
  • Should be marked as real answer. Allthough its a hack, it may be the only thing that works consistently. A real shame that the new 'default' is not even a part of the regular AndroidSDK.
  • This is the only answer that says how to change from the default layout.
  • this is not work for android studio 3.4
  • This is the ONLY answer, which actually answers the question without relying on a hack. Thanks, it really should be upvoted
  • this did not work for me . ! i changed the the root_tag to relative layout as suggested in both the files, but in vain !
  • can you provide a screenshot ?
  • This forces the width and height to static numbers. If this approach is needed, then it would be better to right click on ConstraintLayout and do inferConstraints so as to make width and height as Match_parent