2017-09-21 7 views
0

J'ai créé une barre d'outils personnalisée pour mon application. Mais pour une raison encore inconnue sur mon Android 4.4 KitKat dispositifs le texte vertical centré ne sont pas centrés correctement. Sur tous les appareils Android 5+, cela fonctionne très bien.Texte du titre de la barre d'outils personnalisée Android ne centrant pas sur les appareils Android 4.4

Il semble que sur 4.4 à la fin (au lieu du centre) du texte d'un textView est alligned avec le centre de la barre d'outils.

Quelqu'un a-t-il une idée pour résoudre ce problème?

ici pour xml au cas où vous souhaitez voir

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

Répondre

0

fixe: le TEXTSTYLE contenait une valeur pour lineSpacingExtra

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

Ce qui a provoqué la TextView ajouter une marge supplémentaire en bas du TextView uniquement, ce qui évite de centrer le texte correctement dans la barre d'outils.

Cela s'est produit uniquement sur KitKat & Les périphériques Lollipop ne sont pas concernés par cela.