Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Activity title ellipse to middle?

Tags:

java

android

I have an Activity whose title keeps change, but sometimes its long and get ellipses by end. Can I set ellipse to middle ?

like image 731
xmen Avatar asked May 28 '12 03:05

xmen


2 Answers

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);
    }
like image 74
Diego Torres Milano Avatar answered Sep 21 '22 17:09

Diego Torres Milano


    ((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

like image 35
xmen Avatar answered Sep 20 '22 17:09

xmen