richeditor-android icon indicating copy to clipboard operation
richeditor-android copied to clipboard

进入编辑模式

Open qidianli opened this issue 4 years ago • 1 comments

1 RichEditor控件,在用户想再次进入编辑的时候如何设置html内容并进行编辑模式 2 图片插入后如何换行 3 图片宽度充满屏幕,高度自适应,这一块代码有没有设置的

qidianli avatar Apr 20 '20 09:04 qidianli

1.setHtml() 2.第二个问题我也想知道。 3.插入图片的时候压缩图片到屏幕宽度就可以了 public static Bitmap sizeCompress(Bitmap bmp,float getWidthImae) {

    Bitmap scaledBitmap = null;
    if(bmp!=null){
        // 尺寸压缩倍数,值越大,图片尺寸越小
        int w = bmp.getWidth();
        int h = bmp.getHeight();
        float ratio = w/getWidthImae;
        // 压缩Bitmap到对应尺寸
        Bitmap result = Bitmap.createBitmap((int)(w/ratio), (int)(h/ratio), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(result);
        Rect rect = new Rect(0, 0, (int)(w/ratio), (int)(h/ratio));
        canvas.drawBitmap(bmp, null, rect, null);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // 把压缩后的数据存放到baos中
        result.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
        scaledBitmap = BitmapFactory.decodeStream(isBm);

    return scaledBitmap;
}