Code example for StaticLayout

Methods: getLineCount, getLineEnd

0
    public static String s(int id) {
        return context.getResources().getString(id);
    } 
 
    public static String cutOneLine(String str, TextPaint textPaint, int width) {
        StaticLayout layout = new StaticLayout(str, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1, 0, true);
        if (layout.getLineCount() > 1) {
            str = str.substring(0, layout.getLineEnd(0)).trim();
        } 
        return str;
    } 
 
    public static boolean isWifiEnable() { 
        WifiManager wifiManager = (WifiManager) context.getSystemService(Service.WIFI_SERVICE);
        return wifiManager.isWifiEnabled();
    } 
}