2017-09-21 19 views
0

내 앱용 사용자 정의 툴바를 만들었습니다. 하지만 내 안드로이드 4.4 KitKat 장치에서 나에게 아직 알려지지 않은 이유가 있기 때문에 수직 중심의 텍스트가 올바르게 가운데에 있지 않습니다. 모든 안드로이드 5 이상의 장치에서 잘 작동합니다.Android 사용자 정의 툴바 제목 텍스트가 Android 4.4 디바이스를 중심으로하지 않습니다.

textView의 텍스트가 중앙 대신 4.4에서 아래처럼 보이는 것은 툴바의 중심으로 정렬됩니다.

누구나 어떻게 해결할 수 있을까요? 다음 경우 XML로

당신이보고 싶습니다 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/toolbar_root" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      tools:background="@color/background_default"> 

<LinearLayout 
    android:id="@+id/toolbar_icon_left_container" 
    android:layout_width="48dp" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" 
    android:background="?selectableItemBackgroundBorderless" 
    android:clickable="true"> 

    <ImageView 
     android:id="@+id/toolbar_icon_left_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" 
     android:src="@drawable/back"/> 

</LinearLayout> 

<TextView 
    android:id="@+id/toolbar_title" 
    android:fontFamily="@font/museo700" 
    android:singleLine="true" 
    android:layout_toRightOf="@+id/toolbar_icon_left_container" 
    android:layout_toLeftOf="@+id/toolbar_text_right" 
    style="@style/TextStyle5" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_toEndOf="@+id/toolbar_icon_left_container" 
    android:gravity="center_vertical" 
    tools:text="Selecteer een leverdatum"/> 

<TextView 
    android:id="@+id/toolbar_text_right" 
    style="@style/TextStyle7" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="@dimen/screen_edge_margin" 
    android:background="?selectableItemBackgroundBorderless" 
    android:clickable="true" 
    android:gravity="right|center_vertical" 
    android:minWidth="48dp" 
    tools:gravity="right|center_vertical" 
    tools:text="Help"/> 

답변

0

는 고정 다음 텍스트 스타일이에 텍스트 뷰를 일으킨

<item name="android:lineSpacingExtra">10sp</item> 

lineSpacingExtra

에 대한 값을 포함 TextView의 아래 부분에 여분의 여백을 추가하여 도구 막대에서 텍스트를 정확히 가운데 맞추지 않습니다.

이것은 KitKat & 롤리팝 기기에서만 영향을받지 않습니다.