B4A Class [B4X] [XUI] AS Gradients Panel

First, i spend a lot of time in creating views, some views i need by my self, but some views not and to create a high quality view cost a lot of time. If you want to support me, then you can do it here by Paypal. :)

This is the First Version, if you have bugs, then ask in the comments.

With this view you can create gradients panels, with dynamic colors and sizes.
Looks better in real... i found it funny, that a .mp4 with high quality has a smaller size than a .gif

AS Gradients B4A 1.gif
AS Gradients B4J 1.gif

  • Add View per code
  • Change Color at runtime
  • Generate random colors
  • Gradients with less code
  • Click Event

Author: Alexander Stolte
Version: 1.0

  • ASGradientsPanel
    • Events:
      • Click
    • Functions:
      • AddViewPerCode (Base As B4XView, pcolors As Int(), pOrientation As String) As String
        Adds the view per code, note the Base_Resize event is not fired on this method, you have to resize the view on your own
      • Class_Globals As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • generate_rnd_clr As Int
      • GetBase As B4XView
      • GetBaseGradient As B4XView
      • getBL_TR As String
        Bottom Left - Top Right
      • getBOTTOM_TOP As String
      • getBR_TL As String
        Bottom Right - Top Left
      • getColors As Int()
      • getCornerRadius As Double
      • getLEFT_RIGHT As String
      • getOrientations As String
      • getRECTANGLE As String
      • getRIGHT_LEFT As String
      • getTL_BR As String
        Top Left - Bottom Right
      • getTOP_BOTTOM As String
      • getTR_BL As String
        Top Right - Bottom Left
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • RefreshGradient As String
        Build the Gradient new based on the mBase width and height
      • RefreshView As String
        Triggers the Base_Resize event
      • setColors (pcolors As Int()) As String
      • setCornerRadius (pCornerRadius As Double) As String
      • setOrientations (pOrientation As String) As String
    • Properties:
      • BL_TR As String [read only]
        Bottom Left - Top Right
      • BOTTOM_TOP As String [read only]
      • BR_TL As String [read only]
        Bottom Right - Top Left
      • Colors As Int()
      • LEFT_RIGHT As String [read only]
      • RECTANGLE As String [read only]
      • RIGHT_LEFT As String [read only]
      • TL_BR As String [read only]
        Top Left - Bottom Right
      • TOP_BOTTOM As String [read only]
      • TR_BL As String [read only]
        Top Right - Bottom Left
If you like my work, then spend me a coffe or two :)


  • AS Gradients B4J.zip
    24.5 KB · Views: 386
  • AS Gradients B4A.zip
    38.2 KB · Views: 483
  • ASGradientsPanel.b4xlib
    2.2 KB · Views: 342
Last edited:


Active Member
Licensed User
You cannot add child views to this panel like you can with a normal panel, is that intended?