Code example for Rect

Methods: width

0
    } 
 
    @Override 
    public Layout getTextLayoutAt( int position ) {
        String text = listPoints.get( position ).getText();
        Rect bounds = new Rect();
        textPaint.getTextBounds( text, 0, text.length(), bounds );
 
        int width = Math.min( bounds.width(), maxTextWidth );
        StaticLayout staticLayout = new StaticLayout( text, textPaint, width, Alignment.ALIGN_CENTER, 1, 0, false );
        return staticLayout;
    } 
 
    @Override 
    public Point getTextPointAt( int position ) {
        Drawable drawable = getDrawableAt( position );
        Layout textLayout = getTextLayoutAt( position );
        Point point = listPoints.get( position );
        final int marginX = drawable.getIntrinsicWidth() / 4 + margin;
        final int marginY = drawable.getIntrinsicHeight() / 4 + margin;
        int textX = point.x > screenWidth / 2 ? point.x - marginX - textLayout.getWidth() : point.x + marginX;