如何在GradientDrawable上绘制位图?

时间:2016-04-28 21:31:54

标签: android canvas bitmap

这是我的非工作代码:

 GradientDrawable sh = new GradientDrawable();          // create a gradient drawable.          
 Bitmap cbm = bmp.copy(Bitmap.Config.ARGB_8888, true);  // do not use an immutable bitmap.

 Canvas cv = new Canvas(cbm);  //create a canvas using the mutable bitmap.

 sh.setAlpha(255);  // this has no effect?
 sh.draw(cv);       // does nothing?

 sh.setStroke(thik, clr);      //this works fine.  
 sh.setCornerRadius(radius);   // This works fine. 

 v.setBackgroundDrawable(sh);  // displays a rounded corner box with transparent center (no bitmap!!).

我确定我做错了什么,但我不知道我做错了什么。我希望这不是另一种情况,Java代码将一个简单的函数调用转换为一个完整的事件,其中包含catch和stuff的消息。

帮助?

基本上我需要的是一个按钮,其角落有点圆角,中风为2或3像素,中心有一个拉伸的位图(圆角描边应覆盖位图的角落)。

感谢。

0 个答案:

没有答案