IconButton - Add a icon or an Picture to a button

DonManfred

Expert
Licensed User
Longtime User
IconButton
Version:
1.11
  • IconButton
    Events:
    • Click()
    • Down()
    • HoverEnter()
    • HoverExit()
    • LongClick()
    • Up()
    Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
      programmatically add the view (the Button)
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • setIcon (LeftSide As Boolean, d As Drawable)
    • setPadding (left As Int, top As Int, right As Int, bottom As Int)
      Sets the Padding for this Button
    Properties:
    • Background As Drawable [write only]
      Sets the Buttons background
    • BackgroundColor As Int [write only]
      Sets the Buttons background color
    • BackgroundDrawable As Drawable [write only]
      Sets the Buttons background drawable (deprecated)
    • Enabled As Boolean [write only]
      Sets the Buttons enabled state
    • Height As Int
    • IconPadding As Int [write only]
      Set the Padding between Text and Icon
    • Left As Int
    • Text As String [write only]
      Set the Text
    • TextAlignment As Void
      Sets the Alignment for this Button
    • TextColor As Int [write only]
      Sets the Textcolor for this Button
    • Top As Int
    • Typeface As Typeface
      Sets the Typeface for this Button
    • Width As Int


B4X:
    Dim bm As BitmapDrawable
    bm.Initialize(LoadBitmap(File.DirAssets,"ic_action_alarm.png"))
    ib1.Text = "Button"
    ib1.IconPadding = 50
    ib1.setIcon(True,bm)

    Dim bm As BitmapDrawable
    bm.Initialize(LoadBitmap(File.DirAssets,"ic_action_achievement.png"))
    ib2.Text = "Button"
    ib2.IconPadding = 50
    ib2.setIcon(False,bm)

    Dim bm As BitmapDrawable
    bm.Initialize(LoadBitmap(File.DirAssets,"ic_action_android.png"))
    ib3.Text = "Button"
    ib3.IconPadding = 50
    ib3.setIcon(False,bm)

IconButton001.png
 

Attachments

  • IconButtonEx.zip
    17.2 KB · Views: 1,790
  • libIconButtonV1.1.1.zip
    8.7 KB · Views: 1,564
Last edited:

RandomCoder

Well-Known Member
Licensed User
Longtime User
I've not had chance to play with any of your latest libraries yet but just wanted to post here to show my appreciation for the hard work you have obviously put in to creating these excellent additions to B4A for us.

Thank you.
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Time my friend, there's never enough time! I can't believe we're almost in March, where did January and February go? :confused:
 

DonManfred

Expert
Licensed User
Longtime User
Time my friend, there's never enough time!
hehe, fully aggree

I can't believe we're almost in March, where did January and February go? :confused:
Are you in a timemachine or what let you think it´s already march? :D

Edit: I needed to google "Almost"... Ok, no timemachine ;)

Time is running away fast if you are not boring. Aggree ;-)
 

Mahares

Expert
Licensed User
Longtime User
@DonManfred: This is a very nice library. You have become a powerhouse in just a short period of time since you joined the forum.
Can you please add a few more properties like: TextColor, etc. I tried to change the text color in the designer but it does not have any effect.
 

leidex

Member
Licensed User
Longtime User
Hi Manfred,
nice work!
How do i check which button is clicked?

Thank you
 

DonManfred

Expert
Licensed User
Longtime User
You can add the button in designer and set the correct eventname. Then you just need to manually create the clickevent.
Asuming you set "IB" as the eventname then you need a sub like
B4X:
Sub IB_Click
    Log("Button clicked")
End Sub
You can create this eventsub with

sub+[space]+[tab]+iconbutton

too.

Sadly the event can not be set in designer... I dont know why. Or better said; i dont know whether i can do something to let the designer create this event with the contectual popup to create members.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
You have become a powerhouse in just a short period of time since you joined the forum.

I´m here since 2 Years now... I started learning java (to be able to write new libraries (because i LOVE B4A and i want new Features to it...)) three months ago

Can you please add a few more properties like: TextColor, etc.
What exactly? I dont want to blow up the lib with dozend of methods which will not be used and just make the lib bigger
But i can add more methods though
 
Last edited:

woniol

Active Member
Licensed User
Longtime User
Would it be possible to add events:

Down
Up
LongClick

to make compatible with standard B4A button?
 
Top