placer au centre de l'écrant linear layout code example

Example: placer au centre de l'écrant linear layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="vertical">

       <android.support.v7.widget.Toolbar
           android:id="@+id/toolbar"
           android:layout_width="match_parent"
           android:layout_height="?attr/actionBarSize"
           android:background="@color/colorPrimaryDark"
           android:elevation="4dp"
           android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />


       <RelativeLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent">

           <Button
               android:id="@+id/button2"
               android:layout_width="200dp"
               android:layout_height="wrap_content"
               android:layout_centerInParent="true"
               android:background="@color/colorPrimaryDark"
               android:text="text"
               android:textSize="22dp" />

       </RelativeLayout>

</LinearLayout>

Tags:

Misc Example