Sean's Note: [Android 4.4 Issue] TextView 無法垂直置中

2016年10月13日 星期四

[Android 4.4 Issue] TextView 無法垂直置中

The TextView cannot center vertically:

<TextView 

                android:id="@+id/toolbar_title" 
                android:layout_width="match_parent" 
                android:layout_height="match_parent"
                android:visibility="visible" 
                tools:text="Hello" 
                android:layout_gravity="center_vertical" 
                android:gravity="center_vertical" 
                android:textSize="@dimen/font_slarge"/> 

It seems an OS issue that android:gravity="center_vertical" doesn't work when android:layout_height="match_parent". The issue can be fixed when giving the specific height.


Ref: https://code.google.com/p/android/issues/detail?id=59368

沒有留言:

張貼留言