如何在Android上优化活动标题

时间:2012-06-15 21:58:58

标签: android android-activity title

我正试图将活动的标题放在一边,有人可以告诉我该怎么做吗?

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?

2 个答案:

答案 0 :(得分:0)

试试这个:http://it-ride.blogspot.pt/2010/07/android-title-marquee.html 那里的一些人说它有效,有些人说没有。

答案 1 :(得分:-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