纹理在Android中绘制对象?

sun*_*nil 3 android view

我正在使用http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/comment-page-1/#comment-14326上的代码来构建自定义视图.

我想显示图像而不是通过代码绘制手.我试过设置手的纹理但没有取得任何成功.

任何人都可以让我知道如何设置图像代替手?

Nou*_*tti 5

您可以使用BitmapShader执行此操作:

  Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.images);
  fillBMPshader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
  mPaint.setShader(fillBMPshader); 
Run Code Online (Sandbox Code Playgroud)