0

I want set the background image for a panel in the center of it. But how can I set the image in center of panel?

I wrote this code:

Dim panel21 As Panel
panel21.Initialize("panel21")
ScrollView1.Panel.AddView(panel21, 0, 138%y, 100%x, 12%y)
panel21.SetBackgroundImage(LoadBitmap(File.DirAssets, "home.png"))

But I don't want to set background for it in designer mode.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mR.Rian
  • 615
  • 2
  • 6
  • 28

1 Answers1

0

If you want to center screen that panel, you can add in to Activity!

You can add this picture center of the screen like this;

Dim p as Panel
p.initialize("p")
p.SetBackgroundImage(LoadBitmap(dir,fileName))

Dim W As Int = 400dip 'This is picture width
Dim H As Int = 300dip ' and height

Activity.AddView(p, (100%x - W)/2, (100%y - H)/2 , W, H)

if you sure to add scrollview, you must add scrollview to activiy first, and replace 100%x with scrollview.width and 100%y with scrollview.height.

Serhat MERCAN
  • 1,078
  • 3
  • 14
  • 31