Android Studio 2.2 Preview Big Changes!
Written by Mike James   
Friday, 20 May 2016

As this year's Google I/O draws to a close the Android Studio 2.2 preview was the star of the show. It brings really big changes to Android programming. 

Android Studio is developing fast - perhaps too fast for some. 

The key and important update is to the Layout Editor. If you have used Android Studio before you will know that the Layout Editor is good but occasionally difficult to use. The standard layout container - relative - is also a bit temperamental and positioning things on the screen can some times feel like herding cats. Things are much better in 2.2.

When you first open the new Android Studio you are going to be very confused by the way the Layout Editor looks. There are now two displays showing you what your layout looks like. This is a very good reason for buying a bigger monitor as soon as possible or switching the new blueprint view off. 

The key new feature, however, is the Constraint Layout. This is now used as the default layout in all of the New Project templates. You can also switch the standard relative layout to a constraint layout with a single click.

As far as I can tell this should just work as the constraint layout adds features to the layout. A constraint can be applied to an anchor point, an edge or a guideline. Reading the documentation makes it sound a bit complicated. but when you use it in the editor it begins to make sense. The use of strange wavy arrows might freak out some users - it did me - but they work in much the same way as the relative layout.  If the curved arrays do unnerve you then prepare for the springs - the wavy lines. These allow you to specify a pair of springy constraints that ensure that the View will be centred no matter what the size of the screen.

You can see both the curvy arrows and the springy constraints in the following gif:

asedit

 

One of the strange things about the layout is that if you just plop something down on the designer with autoconnect off and without specifying any constraints then the editor "knows" its there but doesn't give it the absolute position you think it might have. Instead it is positioned at 0,0, i.e. top left. If you want it to have the position you dropped it at you can use the Infer Constraints icon to let the system figure out what reasonable constraints to apply. 

You can also edit the constraints in the properties window - and this is another all new feature which might have you wondering what the symbols and sliders are all about:

 

props

 

The new Layout Inspector can be used to explore and debug your layout as it runs on the emulator.  It will analyse and display the current View hierarchy in real time. 

So is the new designer and layout a good thing?

I think so. After using it for only a few hours I'm still finding it a bit cluttered and slightly intimidating, but as time goes on it is getting better and watching constraints being applied in real time is fun.  

What you are used to is always easier than something new. Overall I think it is a big step in the right direction and as the layouts it produces are flat they are going to be faster than layouts built with nested linear layouts, for example. It is suggested that in the future the Constraint Layout is the only one you need to use. 

Compared to the radical overhaul of the layout editor the other new features are slightly more modest.

There is a new Firebase plugin to get you using it for everything from analytics to advertising, see Google Revamps Firebase As App Platform.  

Code analysis has been improved and now supports Java 8.  The good news is that the new Jack compiler which is now used allows some Java 8 language features - like lambdas! 

Yes, at long last lambdas come to Android programming! This makes it much easier to write event handlers and you can use the coding style on all versions of Android. Not only have we moved to some Java 8 features, the library is now OpenJDK - and you shouldn't notice any changes.

For C/C++ NDK programmers Android Studio will now use your CMake and NDK-Build files. 

"Android Studio 2.2 improves C++ development with the ability to edit, build, and debug pre-existing Android projects that use ndk-build or CMake rather than Gradle. Additionally, the existing lldb C++ debugger is now even better with project type auto-detection and a Java language aware C++ mode that lets you use a single debugger process to inspect both Java language and C++ runtimes."

Finally there is a merged manifest viewer, a test recorder that will capture clicks and other user interaction so you can play it back, and an APK Analyzer that will find problems and help you fix them. 

Add to all of this the fact that it comes with Android N for you try out and this is quite a big release. 

I know this is ungrateful, but I couldn't find anything new about the data binding library. It isn't mentioned in the Android Studio 2.2 announcement and there still seems to be no support for it from the designer - perhaps 2.3 will include it. 

You probably do need to download 2.2 and checkout the new constraint layout, it could be the only layout you use in the future. So far it also seems to be stable and usable. 

 

android22

 

 

More Information

Android Studio 2.2 Preview - New UI Designer & Constraint Layout

Related Articles

Android Studio 2 Is Launched - A New Era 

Android Studio 2 Beta Is Usable 

Android Studio 2.0 Preview Now With Emulator 

Android Studio 2 In Preview 

Android Studio 1.5 Released - Just Some Bug Fixes, Don't Get Excited

Visual Studio V Android Studio

MarshMallow Is Coming!

Android Studio 1.3 Released

Android Data Binding - Say Goodbye To FindViewById    

Android M - Still No Name But An SDK Update And NDK Support       

Google Drops Support For Eclipse - It's All Android Studio Now       

Android Adventures - Getting Started Creating A UI

Android Adventures - Mastering Fragments

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin

 

Banner


Can You Solve The GCHQ Christmas Challenge 2024
20/12/2024

The GCHQ Christmas Challenge has become a pre-Christmas tradition. While it is primarily targeted at school students working in teams, GCHQ encourages both children and adults to give it a try.



PHP 8.4 Adds Property Hooks
26/11/2024

PHP 8.4 is available with improvements including property hooks, asymmetric visibility, and an updated DOM API.


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Friday, 20 May 2016 )