광선 효과가 잘 작동합니다. 내 의심은 어떻게 광선 효과를 숨기는 것입니까? 내 이미지 뷰를 클릭하면 그 시간에만 내 글로우 효과를 표시하고 싶습니다. 클릭하면 반짝이는 효과를 숨기고 표시하는 방법을 알려주세요.광선 효과를 숨기는 방법?
코드 :
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// An added margin to the initial image
int margin = 24;
int halfMargin = margin/2;
// the glow radius
int glowRadius = 16;
// the glow color
int glowColor = Color.rgb(0, 192, 255);
// The original image to use
Bitmap src = BitmapFactory.decodeResource(getResources(),
R.drawable.test);
// extract the alpha from the source image
Bitmap alpha = src.extractAlpha();
// The output bitmap (with the icon + glow)
Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,
src.getHeight() + margin, Bitmap.Config.ARGB_8888);
// The canvas to paint on the image
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setColor(glowColor);
// outer glow
paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER));
canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);
// original icon
canvas.drawBitmap(src, halfMargin, halfMargin, null);
setContentView(R.layout.activity_main);
((ImageView) findViewById(R.id.bmpImg)).setImageBitmap(bmp);
}
}
현재의 스크린 샷 :
R.id.bmpImg. 마지막 줄에 대한 설명을하고 싶습니까? –
@ Mr.Hyde 그것의 아무 것도 내 레이아웃에서 이미지 뷰를 사용하므로 id를 통해 해당 이미지 뷰를 사용하고 있습니다. 그게 다야. 이 형식을 사용할 수있는 또 다른 형식입니다. ImageView img = (ImageView) findViewById (R.id.bmpImg); 2.img.setImageBitmap (bmp); – balaji