I am trying to center a view but its not. The root container is a RelativeLayout. This only happens when phone is in Portrait orientation multi-window mode. I have tried putting the view in LinearLayout, RelativeLayout and FrameLayout but nothing works. I am amazed the same layout works when in landscape orientation multi-window mode.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_relative"
android:background="@color/colorAccentWhite"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:clickable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="@+id/name_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:textColor="@color/black"
android:visibility="invisible" />
</RelativeLayout>
</RelativeLayout>
The TextView is positioned Top Left instead of centered horizontally. How can I make it work?