2017-11-03 18 views
0

뷰를 중앙에 놓으려고하는데, 그렇지 않습니다. 루트 컨테이너는 RelativeLayout입니다. 이것은 전화기가 세로 방향 다중 창 모드 인 경우에만 발생합니다. LinearLayout, RelativeLayout 및 FrameLayout보기를 시도했지만 아무것도 작동하지 않습니다. 프리젠 테이션 방향의 멀티 윈도우 모드에서 동일한 레이아웃이 작동하는 것에 놀랐습니다.중력 = "센터"가 다중 창에서 세로 방향으로 작동하지 않습니다.

<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> 

텍스트 뷰는 좌측 상단에 위치하는 대신 수평 중심. 어떻게 작동시킬 수 있습니까?

답변

0

변경 'match_parent'천만에요

+0

에서 'wrap_content'여기에 사용되는 텍스트 뷰의 폭, 나는 그것이 일 기뻐요! – GouravJn