Android Question Change color slidemenu

devmobile

Active Member
Licensed User
Hello
I use SlidingMenu in my app
When i touch slidemenu and open it,i want to add black or shadow layer on activity
I attach sample image
Thanks
 

Attachments

  • Untitled-1.jpg
    Untitled-1.jpg
    22.3 KB · Views: 261

devmobile

Active Member
Licensed User
I found solution
I add panel to activity and set gray color to it
And when menu opend,i show panel and when menu is hidden,i hide panel

below code
B4X:
Dim overlayPanel as Panel
overlayPanel.Initialize("")
    overlayPanel.Color = Colors.ARGB(170,30, 30, 30)
    getCurrentActivity.AddView(overlayPanel,0,0,100%x,100%y)
    overlayPanel.Visible = False
   
    Dim jo As JavaObject = sm
    Dim event As Object = jo.CreateEventFromUI("com.jeremyfeinstein.slidingmenu.lib.SlidingMenu$OnOpenListener", "Open", Null)
    jo.RunMethod("setSecondaryOnOpenListner", Array(event)) 'setSecondaryOnOpenListner
   
    Dim jo As JavaObject = sm
    Dim event As Object = jo.CreateEventFromUI("com.jeremyfeinstein.slidingmenu.lib.SlidingMenu$OnCloseListener", "Close", Null)
    jo.RunMethod("setOnCloseListener", Array(event))

Sub Close_Event (MethodName As String, Args() As Object) As Object
   overlayPanel.SetVisibleAnimated(500,False)
End Sub

Sub Open_Event (MethodName As String, Args() As Object) As Object
   overlayPanel.SetVisibleAnimated(500,True)
End Sub

Sub getCurrentActivity As Activity
   Dim r As Reflector
   r.Target = r.GetActivityBA
   Return r.GetField("vg")
End Sub
 
Upvote 0
Top