안드로이드 개발 질문/답변
(글 수 45,052)
액티비티를 실행해서 동작하도록 만들었습니다.
그런데 그위에 다시 이미지를 뿌리려고 하니...
이전에 만들어 놓은 액티비티가 가려지는 것 같습니다.
이거.. 처리할 방법이 없을까요?
public class main extends Activity {
private Bitmap mBitmap;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
setContentView(R.layout.main);
setContentView(new ImageView(this));
}
public class ImageView extends View{
private Bitmap mViewBitmap;
private int mWidth = 0;
private int mHeight = 0;
public ImageView(Context context) {
super(context);
setFocusable(true);
int[] colors = createColors();
mViewBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888);
mViewBitmap.setPixels(colors,0, mWidth, 0, 0, mWidth, mWidth);
}
@Override
protected void onDraw(Canvas canvas) {
int winWidth = getWidth();
int winHeight = getHeight();
// canvas.drawColor(Color.WHITE);
canvas.drawBitmap(mViewBitmap, winWidth/2-mWidth, winHeight/2 - mHeight,null);
canvas.translate(0, mViewBitmap.getHeight());
super.onDraw(canvas);
}
private int[] createColors(){
int[] colors = null;
mWidth = mBitmap.getWidth();
mHeight = mBitmap.getHeight();
colors = new int[mWidth * mHeight];
mBitmap.getPixels(colors, 0, mWidth, 0, 0 , mWidth, mHeight);
return colors;
}
}
}



ImageView(this), new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));이렇게 해보세요..