2013-03-10 49 views
0

有沒有一種方法,以防止越來越裁剪的動作條(福爾摩斯)的標題(如ThisIsMyTi ...)安卓:ActionBarSherlock標題Ellipsize

我想總能看到全長的稱號,所以除了沒有硬件菜單按鈕的設備上的溢出菜單按鈕,標題應始終具有最高優先級。

如果有解決方案,會很好。設置標題爲空不起作用的ellipsize,它只是被裁剪不...

回答

0

添加頂部:

private TextView titleTV; 

在你的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); 

而且在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> 

您可以設置標題與

titleTV.setText(t);