get Truncate End String - Android android.text

Android examples for android.text:TextPaint

Description

get Truncate End String

Demo Code


//package com.java2s;

import android.graphics.Paint;

import android.text.TextPaint;
import android.text.TextUtils;

public class Main {
    public static String getTruncateEndString(String aSrcString,
            Paint aPaint, int aWidth) {
        if (aSrcString == null) {
            return "";
        }/*w w w.  ja va  2 s  .  com*/
        return TextUtils.ellipsize(aSrcString, new TextPaint(aPaint),
                aWidth, TextUtils.TruncateAt.END).toString();
    }
}

Related Tutorials