B4A Library Flat Button

Discussion in 'Additional libraries, classes and official updates' started by Johan Schoeman, Mar 14, 2015.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    This library is based on the project that is posted here. See attached project and screenshot. Library files are in the /files folder of the project.

    Other than the parameters that are set in the project you can also set the Left, Top, Width, and Height of the customview buttons.

    Buttons have a kind of eye-blinking effect when clicked. You have to download and install it to appreciate what the buttons are doing.

    Code:
    CustomView1.Left = 0%x
    CustomView1.Top = 
    0%y
    CustomView1.Width = 
    15%x
    CustomView1.Height = 
    15%y
     

    Attached Files:

    Last edited: Mar 15, 2015
    Mashiane, Isac, daemon and 6 others like this.
  2. incendio

    incendio Well-Known Member Licensed User

    Tried it with gradient background, got an error.

    Here are my codes :
    Code:
    Dim bd As GradientDrawable
        
    Dim cl(2As Int
       
        cl(
    0) = Colors.Black
        cl(
    1) = Colors.RGB(234,24,24)
        bd.Initialize(
    "BOTTOM_TOP",cl)

        CustomView4.ButtonColor = 
    Colors.ARGB(150,255,255,255)
        CustomView4.CornerRadius = 
    20dip
        CustomView4.ShadowColor = 
    Colors.ARGB(100,255,255,255)
        CustomView4.ShadowHeight = 
    10dip
        CustomView4.Height = 
    20%y
        CustomView4.ShadowEnabled = 
    True
        CustomView4.ImageBitmap = 
    LoadBitmap(File.DirAssets,"google+48.png")
        CustomView4.ButtonText = 
    "Button 4"
        CustomView4.ButtonTextSize = 
    25
        CustomView4.ButtonTextColor = 
    Colors.Green
        CustomView4.Width = 
    150dip
        CustomView4.Background = bd
     
  3. Johan Schoeman

    Johan Schoeman Expert Licensed User

    The original flat button Java code does not accommodate setting a gradient for the buttons. But it can be added
     
    incendio likes this.
  4. Johan Schoeman

    Johan Schoeman Expert Licensed User

    It is actually very simple to re-create these "flat buttons" with B4A code only (including GradientDrawable). See attached project. You can tweak the buttons to your hearts wish without having to rely on the capability of any library whatsoever.

    Edit: See V2. Either text or image in the button
     

    Attached Files:

    Last edited: Mar 24, 2015
    incendio and Tom Christman like this.
  5. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Have added some variants to the buttons - click them to see what happens. fiddleAround library files in the /files folder.
     

    Attached Files:

    konradwalsh likes this.
  6. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Have just improved the animations - add designer scripts to make it fit.
     

    Attached Files:

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice