Texture to paint on Android?

I am using the code http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/comment-page-1/#comment-14326 to create a custom view.

I wanted to display an image instead of hand drawing through code. I tried to set the texture for the hand, but was not successful.

Can someone tell me how can I set an image instead of a hand?

+3
source share
2 answers

I was able to apply a texture to draw an object using BitmapShader. In the above example, the texture is applied to the rim, and I applied the same logic to apply the texture to the hand. He works.

+2
source

You can do this with BitmapShader:

  Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.images);
  fillBMPshader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
  mPaint.setShader(fillBMPshader); 
+4
source

Source: https://habr.com/ru/post/1785894/


All Articles