Constraint layout button text center alignment
<p>I'm using the new <code>Constraint</code> layout to build my layout. I need to have <code>Button</code> that occupies almost the entire screen width and that was easy using constraints.</p>

<p><a href="https://i.stack.imgur.com/Wbdmd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wbdmd.png" alt="enter image description here"></a></p>

<p>As you can see in the image I am setting the width to <code>0dp</code> (Any size), but the text don't stick at the center what's usually the normal for a button text.</p>

<p>I've tried:
 - set gravity to center
 - set textAlignment to center</p>

<p>Looks like this properties can't work with <code>0dp</code> width (Any size).</p>

<p>So I've tried to set the width to <code>match_parent</code> using gravity center.</p>

<p><a href="https://i.stack.imgur.com/826Tx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/826Tx.png" alt="enter image description here"></a></p>

<p>It's a little bit to the right.</p>

<p>Does any one know how to fix that behavior ? </p>

<p>Note that i'm using alpha4</p>

<p><code>compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'</code></p>

<p>XML code</p>

<pre><code>&lt;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:id="@+id/content_login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context="br.com.marmotex.ui.LoginActivityFragment"
    tools:showIn="@layout/activity_login"&gt;

    &lt;Button
        android:text="Log in"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/btLogin"
        android:layout_marginTop="48dp"
        app:layout_constraintTop_toBottomOf="@+id/textView6"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="@+id/content_login"
        android:layout_marginRight="16dp"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="@+id/content_login"
        android:layout_marginLeft="16dp"
        android:textColor="@android:color/white"
        android:background="@color/BackgroundColor" /&gt;

&lt;/android.support.constraint.ConstraintLayout&gt;
</code></pre>

<p><strong>EDIT</strong> It was a bug in <code>ConstraintLayout</code> alpha4.</p>

<p><strong>UPDATE</strong> Google has released <strong>alpha5</strong>, the above code now Works.
<a href="http://tools.android.com/recent/constraintlayout-alpha5available" rel="nofollow noreferrer">Release note</a></p>