2016-03-30 19 views
0

Görüntüyü ayarlamak için ImageView'daImageResource ayarlayabilirim ve onDraw orada herhangi bir özel çizim işlemi yapabilir. OnDraw işlevi içinde çizdiğiniz herhangi bir şey SetImageResource'taki görüntü kümesini geçersiz kılar. Demek istediğim, şeffaf bir şey çizersem, bu bölümün SetImageResource tarafından ayarlanan görüntüsünün de şeffaf olmasını sağlar.Android: SetImageResource ve OnDraw

cevap

0

Hayır, olmaz. ImageView

public class TestView extends ImageView { 

    public TestView(Context context) { 
     super(context); 
    } 

    public TestView(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    @Override 
    protected void onDraw(Canvas canvas) { 
     super.onDraw(canvas); 
     //if you call super.onDraw first, then whatever you draw below will be on top of your image 
     canvas.drawARGB(122, 122, 122, 122); 
    } 
} 
'u genişleterek bir görüntüyü test edebilirsiniz.