My guess is you want to draw it on the center of the screen, in your code you refer to the canvas position, then the code you provided will centered the sample image according to the canvas... so it depend on how you declared you View referred by your canvas.
On Apr 20, 8:48 pm, Kromosome <[email protected]> wrote: > Check this out: > > http://developer.android.com/reference/android/widget/LinearLayout.html > > Look under the XML Attributes heading! > > On Apr 19, 4:22 pm, Nandagopal T <[email protected]> wrote: > > > > > > > > > I am using the canvas to display an image in Android. I want an image > > to occupy the center of the screen irrespective of the sizes of the > > screen. So how could i achieve it. > > > This is the snippet that i tried with, Please let me know your ideas > > too. > > > @Override > > protected void onDraw(Canvas canvas) { > > .......... > > .......... > > // This moves the image to right end of the view. > > sampleImage.draw(canvas,getWidth(),getHeight()); > > // Tried with this code too, but not getting the image at > > the center of the screen. > > sampleImage.draw(canvas,getWidth()/2 - imageWidth/ > > 2 ,getHeight()/2 - imageHeight/2); > > > .......... > > .......... > > > Thank you -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

