android tansparency(透明度)

 currntly doing some project related to the draw lines and path on top of the camera view.

 

and it require the image have to be ransparency. i did so some reasch on it, and find this "tansparent Panel on google map". and it is can be download.

 

it said that used Paint.setARGB(a, r, g, b) to set the transparent and color. will, according to the tutorial,

when a = 255, is setted to transparent. however during my test, it is not.

 

when a =0, even the iamge is black color, it does not shows.

when a = 255, the image is full of color, which i mean the image is not tansparent at all.

 

and according to my test on my Eclipse IDE with Android V1.5,

the sutible transparent range( to me) is

120<a<200

when a = 120; the image is nearly disappear.

while when a =200, the image is going to be like a picture which is paste on the screen.

 

below is part of the code i did for testing:

 

 

protected void onDraw(Canvas canvas){
        super.onDraw(canvas);
        float width = getWidth();
        float height = getHeight();
        rectf.set(0, 0, (width/2), (height/2));
        //getWidth() = 320 getHeight()=430 pixl;
       
        trianglePath = new Path();
        innerPaint = new Paint();
        innerPaint.setARGB(170, 75, 75, 75);
        innerPaint.setAntiAlias(true);
       
        boolean clearScreen = this.isClear();
        if(clearScreen){
            //clear view;
            Log.e("xxx","onDraw, clear screen ");
            canvas.drawColor(0, PorterDuff.Mode.CLEAR );
        }else{
            Log.e("xxx","draw arrow");
            float[] arrow =this.calculate();
            float[] org = {(width/4), height,(width*3/4), height};
           
            trianglePath.moveTo(org[0], org[1]);
            trianglePath.lineTo(arrow[4], arrow[5]);
            trianglePath.lineTo(arrow[2], arrow[3]);
            trianglePath.lineTo(arrow[0], arrow[1]);
            trianglePath.lineTo(arrow[8], arrow[9]);
            trianglePath.lineTo(arrow[6], arrow[7]);
            trianglePath.lineTo(org[2], org[3]);


            canvas.drawPath(trianglePath, borderPanit);
            canvas.drawPath(trianglePath, innerPaint);


            canvas.drawRect(rectf, innerPaint);
            //canvas.drawLine((float)org[0], (float)org[1], (float)arrow[0],(float)arrow[1], innerPaint);
        }
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值