![](/img/trans.png)
[英]ActionBarSherlock - Tab Text ellipsize on <Android 3.0 devices
[英]Android: ActionBarSherlock Title Ellipsize
有没有一种方法可以防止裁剪ActionBar(sherlock)的标题(例如ThisIsMyTi ...)
我想始终看到标题的全长,因此标题应始终具有最高优先级,除了没有硬件菜单按钮的设备上的溢出菜单按钮。
如果有解决方案,那就太好了。 将标题的ellipsize设置为null无效,只是剪裁而没有...
在顶部添加:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.