2013-03-10 6 views
0

Y at-il un moyen d'empêcher le titre de la ActionBar (sherlock) de se recadrée (comme ThisIsMyTi ...)Android: ActionBarSherlock Titre Ellipsize

Je voudrais voir toujours le titre en entier, donc le titre doit toujours avoir la priorité la plus élevée, à l'exception du bouton de menu de débordement sur les appareils sans bouton de menu matériel.

Serait bien s'il y avait une solution. Réglage de la ellipsize du titre null ne fonctionne pas, il est de recadrée sans ...

Répondre

0

Ajouter sur le dessus:

private TextView titleTV; 

Dans votre OnCreate:

ActionBar Bar=getSupportActionBar(); 
Bar.setDisplayShowTitleEnabled(false); 
LayoutInflater inflater = LayoutInflater.from(this); 
View customView = inflater.inflate(R.layout.bar, null); 
titleTV = (TextView) customView.findViewById(R.id.title); 
titleTV.setSelected(true); 
Bar.setCustomView(customView); 
Bar.setDisplayShowCustomEnabled(true); 

Et en bar.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/transparent" > 
<TextView 
    android:id="@+id/title" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textSize="19dp" 
    android:singleLine="true"   
    android:duplicateParentState="true" 
    android:fadingEdge="horizontal" 
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:text=""> 
    <requestFocus 
     android:duplicateParentState="true" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 
</TextView> 
</RelativeLayout> 

Vous pouvez définir le titre avec

titleTV.setText(t); 
Questions connexes