Using a custom view may include processing all the drawing yourself, and not just the background image.
Instead, I suggest setting the focus of the view programmatically, as shown:
BitmapDrawable smiley = (BitmapDrawable) getResources().getDrawable(R.drawable.smiley);
Bitmap bgBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bgBitmap);
Matrix matrix = new Matrix();
matrix.setTranslate(0, view.getHeight() % smiley.getIntrinsicHeight());
canvas.setMatrix(matrix);
Paint paint = new Paint();
paint.setShader(new BitmapShader(smiley.getBitmap(), TileMode.REPEAT, TileMode.REPEAT));
canvas.drawPaint(paint);
view.setBackgroundDrawable(new BitmapDrawable(bgBitmap));
Questions to consider:
- I am not sure that view.getWidth () and view.getHeight () are correct methods for getting dimensions.
- What if the emoticon size is larger than the view?
source
share