android studio constraint layout
ConstraintLayout is a layout on Android that gives you adaptable and flexible ways to create views for your apps.
ConstraintLayout, which is now the default layout in Android Studio, gives you many ways to place objects. You can constrain them to their container, to each other, or to guidelines. This allows you to create large, complex, dynamic, and responsive views in a flat hierarchy. It even supports animations!
In this tutorial, you’ll learn to use a multitude of ConstraintLayout‘s features by building an app for a space travel agency. In the process, you’ll learn how to:
Convert from other types of layouts to ConstraintLayout.
Dynamically position UI elements onscreen in relation to other elements.
Animate your views.
What are constraints in Android?
A ConstraintLayout is a android. view. ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread).
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'
}
example constraintlayout in android:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".MainActivity">
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello "/>
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@id/textview1"
android:text="AbhiAndroid"/>
</android.support.constraint.ConstraintLayout>
No comments:
Post a Comment