Bug 58143 - android:textAlignment is not respected in the Designer
Summary: android:textAlignment is not respected in the Designer
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 7.4 (15.3)
Hardware: PC Windows
: --- normal
Target Milestone: 15.6
Assignee: Jérémie Laval
URL: https://developercommunity.visualstud...
Depends on:
Blocks:
 
Reported: 2017-07-13 19:30 UTC by Jon Douglas [MSFT]
Modified: 2017-09-26 18:01 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jon Douglas [MSFT] 2017-07-13 19:30:19 UTC
*Description:

Given the following layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="24dp"
            android:layout_marginRight="24dp"
            android:layout_marginTop="16dp"
            android:layout_weight="1"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-medium"
                android:text="Team A"
                android:textAlignment="center"
                android:textColor="#616161"
                android:textSize="14sp" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:fontFamily="sans-serif-light"
                android:text="0"
                android:layout_gravity="center_horizontal"
                android:textColor="#000000"
                android:textSize="56sp" />
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:text="+3 Points"
                android:background="@color/colorPrimary"
                android:textStyle="bold" />
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="+2 Points"
                android:background="@color/colorPrimary"
                android:textStyle="bold" />
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="Free Throw"
                android:background="@color/colorPrimary"
                android:textStyle="bold" />
        </LinearLayout>
        <View
            android:layout_width="0.5dp"
            android:layout_height="match_parent"
            android:layout_marginBottom="16dp"
            android:layout_marginTop="32dp"
            android:background="#616161" />
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="24dp"
            android:layout_marginRight="24dp"
            android:layout_marginTop="16dp"
            android:layout_weight="1"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-medium"
                android:text="Team B"
                android:textAlignment="center"
                android:textColor="#616161"
                android:textSize="14sp" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:fontFamily="sans-serif-light"
                android:text="0"
                android:textAlignment="center"
                android:textColor="#000000"
                android:textSize="56sp" />
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:text="+3 Points"
                android:background="@color/colorPrimary"
                android:textStyle="bold" />
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="+2 Points"
                android:background="@color/colorPrimary"
                android:textStyle="bold" />
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="Free Throw"
                android:background="@color/colorPrimary"
                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Reset"
        android:layout_marginBottom="8dp"
        android:background="@color/colorPrimary"
        android:textStyle="bold" />
</RelativeLayout>

The Visual Studio Designer renders this as the following(VS4Mac does the same thing):

http://i.imgur.com/j6KJsLQ.png

However Android Studio renders this layout as the following:

http://i.imgur.com/FkV3MNy.png

You will notice on the "Team B" section of the layout, the 0 is properly aligned in the center. This is because of the android:textAlignment="center" property.

However it seems our Designer does not properly render this.

*Expected Results

The "Team B" TextView should be centered as shown in Android Studio and also when Deployed to device

*Actual Results

The "Team B" TextView is not centered

*Other Notes

I had also done some investigation around the themes and AppCompatActivity vs. Activity to where I found that this seems to be an issue with android:textAlignment. When looking at the property value in the Properties window, the value is shown as "0" instead of "center". It seems like this property might be broken in Xamarin.Android as well.

*Version Information

Happens in 15.2 and 15.3
Comment 1 Jérémie Laval 2017-09-26 18:01:52 UTC
Fixed in master and d15-5