Transparent Gradiant Panel?

BarrySumpter

Active Member
Licensed User
Longtime User
Anyone know how to change this tranparent panel
into a transparent GRADIANT panel
to match the attached graphic?

B4X:
Sub Process_Globals
End Sub

Sub Globals

    Dim MapView1 As MapView
    
    Dim Panel1 As Panel
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    If File.ExternalWritable=False Then
        '    OSMDroid requires the use of external storage to cache tiles
        '    if no external storage is available then the MapView will display no tiles
        Log("WARNING NO EXTERNAL STORAGE AVAILABLE")
    End If
        
    Activity.LoadLayout("main")
    

    '    no EventName is required as we don't need to listen for MapView events
    MapView1.Initialize("")
    Activity.AddView(MapView1, 0, 0, 100%x, 80%y)
    
    '    by default the map will zoom in on a double tap and also be draggable - no other user interface features are enabled
    
    '    enable the built in zoom controller - the map can now be zoomed in and out
    MapView1.SetZoomEnabled(True)
    
    '    enable the built in multi touch controller - the map can now be 'pinch zoomed'
    MapView1.SetMultiTouchEnabled(True)
    
    '    set the zoom level BEFORE the center (otherwise unpredictable map center may be set)
    MapView1.Zoom=14
    MapView1.SetCenter(-37.85091702146988, 145.05743605518342)

  Panel1.Initialize("Panel1")
    Activity.AddView(Panel1, 40dip, 50%y, 270dip, 35dip)

    Dim cd As ColorDrawable
  cd.Initialize ( Colors.ARGB( 200, 0, 0, 0) , 5dip )

    Panel1.Background = cd 
    
End Sub


Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub
 

Attachments

  • Transparent Gradiant Panel.png
    6.4 KB · Views: 529
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
LOL

Can't believe I actually working this out meself!

:sign0060:

B4X:
Sub Process_Globals
End Sub

Sub Globals

    Dim MapView1 As MapView
    
    Dim Panel1 As Panel
    
        Dim gd1 As GradientDrawable
         Dim cols1(2) As Int 

End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    If File.ExternalWritable=False Then
        '    OSMDroid requires the use of external storage to cache tiles
        '    if no external storage is available then the MapView will display no tiles
        Log("WARNING NO EXTERNAL STORAGE AVAILABLE")
    End If
        
    'Activity.LoadLayout("")
    

    '    no EventName is required as we don't need to listen for MapView events
    MapView1.Initialize("")
    Activity.AddView(MapView1, 0, 0, 100%x, 80%y)
    
    '    by default the map will zoom in on a double tap and also be draggable - no other user interface features are enabled
    
    '    enable the built in zoom controller - the map can now be zoomed in and out
    MapView1.SetZoomEnabled(True)
    
    '    enable the built in multi touch controller - the map can now be 'pinch zoomed'
    MapView1.SetMultiTouchEnabled(True)
    
    '    set the zoom level BEFORE the center (otherwise unpredictable map center may be set)
    MapView1.Zoom=14
    MapView1.SetCenter(-37.85091702146988, 145.05743605518342)

      Panel1.Initialize("Panel1")
    Activity.AddView(Panel1, 40dip, 50%y, 270dip, 35dip)



  Dim argb() As Int
  
    argb = GetARGB(Colors.Gray)
  
    Log("Gray A = " & argb(0))
  Log("Gray R = " & argb(1))
  Log("Gray G = " & argb(2))
  Log("Gray B = " & argb(3))

    'SetNinePatchDrawable(Panel1, "Panel1")


    Panel1.Color = Colors.argb ( 200, 0, 0, 0)

    Dim cd As ColorDrawable
      cd.Initialize ( Colors.argb( 255, 0, 0, 0) , 5dip )

        'Panel1.Background = cd 





        'cols1(0) = Colors.Gray
        cols1(0) = Colors.argb ( 230, 136, 136, 136)
'        Gray A = 255
'        Gray R = 136
'        Gray G = 136
'        Gray B = 136

                
        'cols1(1) = Colors.Black
        cols1(1) = Colors.argb ( 230, 0, 0, 0)

        
        gd1.Initialize("TOP_BOTTOM",cols1)
        gd1.CornerRadius=5
        Panel1.Background=gd1
    
        
End Sub
Sub GetARGB(Color As Int) As Int()
    Dim res(4) As Int
    res(0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
    res(1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
    res(2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
    res(3) = Bit.And(Color, 0xff)
    Return res
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…