Android Question centering imageview on device

dualznz

Member
Licensed User
Longtime User
Hi all

is there anyway to center the image to be in center.horizontal on any device
i have tried it via addview but it shows on the left hand side using gravity


would i contain the image inside a panel then center the panel on the screen?
 

NJDude

Expert
Licensed User
Longtime User
Something like this:
B4X:
Dim myImage As ImageView

myImage.Initialize("")

Activity.AddView(myImage, 0dip, 0dip, 200dip, 200dip) 'Let's say the ImageView is 200x200

myImage.Left = (100%x - 200dip) / 2
myImage.Top = (100%y - 200dip) / 2
 
Upvote 0

dualznz

Member
Licensed User
Longtime User
excellent cheers works perfect
all i needed was the left not the top and it works great
cheers
 
Upvote 0
Top