layout Bitmap Text Label - Android Graphics

Android examples for Graphics:Paint

Description

layout Bitmap Text Label

Demo Code


//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;

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

public class Main {
    public static StaticLayout layoutBitmapTextLabel(int i, int j, int k,
            int l, Bitmap bitmap, Rect rect, int i1,
            CharSequence charsequence, Point point, TextPaint textpaint,
            boolean flag) {
        point.set(i, j);/*from   ww w  . j  av a2  s .c  om*/
        if (bitmap != null) {
            int j2 = i1 + bitmap.getWidth();
            k -= j2;
            rect.set(i, j, i + bitmap.getWidth(), j + bitmap.getHeight());
            point.set(j2 + point.x, point.y);
        }
        CharSequence charsequence1;
        Object obj;
        StaticLayout staticlayout;
        int j1;
        int k1;
        int l1;
        int i2;
        if (flag)
            charsequence1 = TextUtils.ellipsize(charsequence, textpaint, k,
                    android.text.TextUtils.TruncateAt.END);
        else
            charsequence1 = charsequence;
        if (k <= 0)
            obj = "";
        else
            obj = charsequence1;
        staticlayout = new StaticLayout(((CharSequence) (obj)), textpaint,
                Math.max(k, 0), android.text.Layout.Alignment.ALIGN_NORMAL,
                1.0F, 0.0F, false);
        j1 = Math.max(0, staticlayout.getHeight());
        if (bitmap != null)
            k1 = bitmap.getHeight();
        else
            k1 = 0;
        l1 = Math.max(j1, k1);
        if (bitmap != null)
            rect.offset(0, Math.abs(l1 - bitmap.getHeight()) / 2);
        i2 = Math.abs(l1 - staticlayout.getHeight()) / 2;
        point.set(point.x, i2 + point.y);
        return staticlayout;
    }
}

Related Tutorials