i have a seekbar which i implemented in an xml file. i wanted to place this seekbar on a custom drawable rectangle which i have drawn using the canvas draw method and i have named the the class as "controlButtons.java", i.e different rectangles will act as menus as if.
my main problem is how should i make the seekbar appear on the rectangle without having to make the class "extend linearlayout".
is there a way 开发者_Python百科to import something as a linearlayout and place it on the canvas
hope you'll be able to help me..thanks
raaj
Hope this help:
Bitmap bitmap = Bitmap.createBitmap(seekBarView.getMeasuredWidth(),
seekBarView.getMeasuredHeight() ,Bitmap.Config.ARGB_8888);
Canvas barCanvas = new Canvas(bitmap);
seekBarView.draw(canvas);
baseCanvas.drawBitmap(bitmap, x, y, null);
What I would do is create a bitmap from the canvas that contains the "custom drawable rectangle" using canvas.setBitmap(bitmap);. Then I would use TableLayout in XML to place the bitmap (using imageView) behind the seekbar. The gives you the ability to control the seekbar and get data from it without having to redraw the canvas again completly.
精彩评论