Build the ios Messages Chat Bubble(with bottom right and left tail ) in Android

I want to build the iOS-like Messages chat bubble in Android using the custom view class this is the code that I use to create the rounded corner rectangle and it will be based on the height and weight it will decide the corner radius of all sides.

This rounder corner rectangle refers to This. Then I will modify some.

In this I want to add the tail at the bottom right side and bottom left side based on the use requirement so can anyone help me to complete this iOS-like Messages chat bubble::

    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.Path;
    import android.graphics.RectF;
    import android.util.AttributeSet;
    import android.view.View;
    
    import androidx.annotation.NonNull;
    import androidx.annotation.Nullable;
    
    import org.jetbrains.annotations.Contract;
    
    public class Bubble extends View {
    
        private Paint paint;
        private Path path;
    
        public Bubble(Context context) {
            super(context);
            init();
        }
    
        public Bubble(Context context, @Nullable AttributeSet attrs) {
            super(context, attrs);
            init();
        }
    
        public Bubble(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
            init();
        }
    
        public Bubble(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
            init();
        }
    
        private void init() {

            paint = new Paint();
            paint.setColor(Color.DKGRAY);
            paint.setStyle(Paint.Style.FILL);
            paint.setAntiAlias(true);
    
            RectF rect = new RectF(50f, 50f, 200f, 100f);
            path = getPathOfRoundedRectF(rect, 50f);
        }
    
        @Override
        protected void onDraw(@NonNull Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawPath(path, paint);
        }
    
        @NonNull
        public static Path getPathOfRoundedRectF(
                @NonNull RectF rect,
                float radius
        ) {
            float width = rect.right - rect.left;
            float height = rect.bottom - rect.top;
            float maxRadius = Math.min(width / 2, height / 2);
    
            float finalRadius = Math.min(radius, maxRadius);
    
            Path path = new Path();
            path.moveTo(rect.left + finalRadius, rect.top);
    
            // Top border
            path.lineTo(rect.right - finalRadius, rect.top);
    
            // Top-right corner
            path.arcTo(
                    new RectF(
                            rect.right - finalRadius * 2,
                            rect.top,
                            rect.right,
                            rect.top + finalRadius * 2
                    ), -90f, 90f
            );
    
            // Right border
            path.lineTo(rect.right, rect.bottom - finalRadius);
    
            // Bottom-right corner
            path.arcTo(
                    new RectF(
                            rect.right - finalRadius * 2,
                            rect.bottom - finalRadius * 2,
                            rect.right,
                            rect.bottom
                    ), 0f, 90f
            );
    
            // Bottom border
            path.lineTo(rect.left + finalRadius, rect.bottom);
    
            // Bottom-left corner
            path.arcTo(
                    new RectF(
                            rect.left,
                            rect.bottom - finalRadius * 2,
                            rect.left + finalRadius * 2,
                            rect.bottom
                    ), 90f, 90f
            );
    
            // Left border
            path.lineTo(rect.left, rect.top + finalRadius);
    
            // Top-left corner
            path.arcTo(
                    new RectF(
                            rect.left,
                            rect.top,
                            rect.left + finalRadius * 2,
                            rect.top + finalRadius * 2
                    ), 180f, 90f
            );
    
            path.close();
    
            return path;
        }
}

I wnat the best solution code I want to add the tail at the bottom right side and bottom left side based on the use requirement so can anyone help me to complete this iOS-like Messages chat bubble.

New contributor

Jay Dolar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật