Android Image Buttons

Hi all

I’m struggling showing a Picture in a MobileControl on Android.

Basically, I need to show a set of controls with pictures, and allow the user to select one. On iOS I use a border colour to show the selection of MobileButtons in a MobileContainer.

I can’t work out how to do this on Android. I have AndroidDesignExtensions which lets me load Material icons, but not a Picture from the project.

I can make a MobileCanvas subclass to draw the Picture, but I get recursive Pointerup events called when I tap it and I can’t find a workaround.

I can load a Picture in a MobileImageViewer, but I don’t know how to draw a border, or somehow show which one is selected. I guess I can do selected versions of every image but that is a lot of work to do them all.

Any suggestions for me?

Which version of the Android Design Extensions do you use? It’s possible to do this.

' Add this to your Buttons Opening-Event
Me.SetIconXC(MyPicture) 
Me.SetIconGravityXC(IconGravity.TextStart)

Hi Martin

Thanks for helping!!

I have tried this with 3.5 and the new 4.0 (thank you!!)
Only the shape of the png image shows in the button. I can’t work out what I am doing wrong.

Is there anything else I need to be doing?

This should work in your case:

' Add this to your Buttons Opening-Event
Me.SetIconXC(Stern)
Me.SetIconGravityXC(IconGravityXC.TextStart)
Me.SetIconTintModeXC(PorterDuffModesXC.DST)
1 Like

Hi Martin

Yes this does show the picture now. Thanks!