Hi guys, I'm trying to put an image into a button just like the Cancel and Done buttons in the image below.
I was successful in putting the image with this code.
The problem is, the image always go to the leftmost part of the button. I tried both "setCompoundDrawablesRelativeWithIntrinsicBounds" and "setCompoundDrawablesWithIntrinsicBounds" methods but the result is the same. What I want to do is that both of the image and the text are in the center of the button. Can you help me please?
EDIT: Sorry, I just realized the thread title is wrong. But anyway, this can be used also for labels.
I was successful in putting the image with this code.
B4X:
Dim r As Reflector
Dim ar As AndroidResources
Dim st As String
r.Target = btnDone
st = "android.graphics.drawable.Drawable"
r.RunMethod4("setCompoundDrawablesRelativeWithIntrinsicBounds",Array As Object(ar.GetApplicationDrawable("ic_action_accept"),Null,Null,Null),Array As String(st, st, st, st))
The problem is, the image always go to the leftmost part of the button. I tried both "setCompoundDrawablesRelativeWithIntrinsicBounds" and "setCompoundDrawablesWithIntrinsicBounds" methods but the result is the same. What I want to do is that both of the image and the text are in the center of the button. Can you help me please?
EDIT: Sorry, I just realized the thread title is wrong. But anyway, this can be used also for labels.
Last edited: