无名 发表于 2022-5-8 17:59:24

【菜鸟】设置线性布局背景为QQ气泡

mjava 代码 :

import android.graphics.*;
    import android.graphics.drawable.*;
    setNine(android.widget.LinearLayout view, String path){
      Bitmap bitmap= BitmapFactory.decodeFile(path);
      NinePatchDrawable nineDrawable= null;
         byte[] chunk = bitmap.getNinePatchChunk();// 如果.9.png没有经过第一步,那么chunk就是null
         if(NinePatch.isNinePatchChunk(chunk)) {
             NinePatchDrawable patchy = new NinePatchDrawable(bitmap, chunk, new Rect(), null);
            view.setBackground(patchy);
         }
    }

调用方法:

    gvs(st_vW, Card.8, bubble)
    s path = "/storage/emulated/0/1/images/skin_aio_friend_bubble_nor.9.png"
    call(null, "mjava", "ui.setNine", bubble, path)
    // 注意:Card.8 是线性布局控件
    // path 必须是绝对路径。
http://cdn.u1.huluxia.com/g3/M01/C4/5F/wKgBOV5yGwCAUC9sAACmuGoOg7U668.jpghttp://cdn.u1.huluxia.com/g3/M01/C4/5F/wKgBOV5yGwOAUPSMAAPCiumAMsU889.jpg
页: [1]
查看完整版本: 【菜鸟】设置线性布局背景为QQ气泡