I have a view with 2 TextViews in a horizontal LinearLayout, each with a weight of 1.
The second TextView was like this:
<TextView
android:id="@+id/info_button"
style="@style/TextBlue"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/bg_ten_percent_black_selector"
android:layout_height="@dimen/card_button_height"
android:text="@string/shop_info"
android:gravity="center"
/>
For some reason, the text would not center horizontally when rendered. However, if I performed a touch on it, it would center then.
I have a fix where I wrap it in an extra LinearLayout which is given the weight, and center the TextView within that, but I was wondering why that workaround is effective when this isn't.
Also, what extra information might be needed here, since this method of centered text usually works. The views are inflated and added as ListView header.