I have an Activity whose title keeps change, but sometimes its long and get ellipses by end. Can I set ellipse to middle ?
You can do this:
final int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
final TextView title = (TextView)getWindow().findViewById(actionBarTitle);
if ( title != null ) {
title.setEllipsize(TextUtils.TruncateAt.MIDDLE);
}
((TextView) ((FrameLayout) ((LinearLayout) ((ViewGroup) getWindow()
.getDecorView()).getChildAt(0)).getChildAt(0)).getChildAt(0))
.setEllipsize(TextUtils.TruncateAt.MIDDLE);
got it from android:set title bar in middle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With