2012-06-15 17 views
2

我想省略活動的標題,任何人都可以讓我知道該怎麼做?如何省略Android上的活動標題

setTitle("My Title"); 
//when the text of the title gets too long, how can I use setEllipsize() here? how can I get the view Id of that title? 
+0

所以也許檢查: http://stackoverflow.com/questions/10779037/set-activity-title-橢圓形到中間 – pawegio

回答

-1

的代碼基於此網頁鏈接 http://it-ride.blogspot.pt/2010/07/android-title-marquee.html

// make the title scroll! 
     // find the title TextView 
     TextView title = (TextView) findViewById(android.R.id.title); 
     // set the ellipsize mode to MARQUEE and make it scroll only once 

     title.setEllipsize(TruncateAt.MARQUEE); 
     title.setMarqueeRepeatLimit(1); 
     // in order to start strolling, it has to be focusable and focused 
     title.setFocusable(true); 
     title.setFocusableInTouchMode(true); 
     title.requestFocus(); 

enter image description here

+0

不幸的是,上面的代碼對我來說不起作用,但是非常感謝回覆! –

+0

你有什麼問題,我會吞噬以解決你的問題。 – al23dev

+0

嗨亞歷山大,問題是我不能將省略號添加到活動標題的文本末尾,當文本變得太長時,標題中的文本將被截斷。 –

相關問題