O'Reilly logo

Mastering Android Studio 3 by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The percent library

The percent support library offers just two layout classes PercentRelativeLayout and PercentFrameLayout. It needs to be added to the gradle build file as a dependency, as follows:

compile 'com.android.support:percent:25.1.1' 

To recreate the layout in the previous section, we need to place AppBarLayout inside PercentRelativeLayout. We can then use a percentage value to set the maximum height of our app bar, as follows:

<android.support.percent.PercentRelativeLayout   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">      <android.support.design.widget.AppBarLayout  android:id="@+id/app_bar" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required