Android Question jfeinstein SlidingMenu and ExpandedListview setting up margin

phukol

Active Member
Licensed User
Longtime User
Hello guys and Happy New year! I would just like to ask how i can implement proper margin in my layout.
Im using 2 different screen a 1080p and a 720p screen. Attach is the screenshot of the margins that i encounter using SlidingMenu by jfeinstein.
What i do is first placing my label,imageview and button inside a scrollview. Afterwards i use an Expandedlistview for me to create a menu that is able to expand and contract.

B4X:
Dim offset As Int = 60dip

   'profile
       Dim pnl3 As Panel
       pnl3.Initialize("")

    Dim smLbl5,smLbl6,smLbl7 As Label
    smLbl5.Initialize(""):smLbl6.Initialize(""):smLbl7.Initialize("")
    smLbl5.Text ="Hi Rommel!":smLbl6.Text ="Your balance as of May":smLbl6.Text ="Your balance as of":smLbl7.Text ="May 20,2014 is P17,230.00"
    smLbl5.TextSize = 18:smLbl6.TextSize = 11:smLbl7.TextSize = 11:
    smLbl5.TextColor = Colors.LightGray:smLbl6.TextColor = Colors.LightGray:smLbl7.TextColor = Colors.LightGray

    Dim img2 As ImageView
       img2.Initialize("")
       img2.Bitmap = LoadBitmap(File.DirAssets,"sm_pic.png")

    Dim btn4 As Button
       btn4.Initialize("btn4")
    Dim sld4  As StateListDrawable
    Dim bmpBtn4Idle,bmpBtn4Press  As BitmapDrawable
    bmpBtn4Idle.Initialize(LoadBitmap(File.DirAssets,"sm_refresh_idle.png")) 
    bmpBtn4Press.Initialize(LoadBitmap(File.DirAssets,"sm_refresh_press.png"))

    sld4.Initialize
    sld4.AddState(sld4.State_Pressed, bmpBtn4Press)
    sld4.AddState(sld4.State_Enabled, bmpBtn4Idle)

    btn4.Background = sld4

    pnl3.AddView(smLbl5,10dip,10dip,100%x-5dip,30dip)
    pnl3.AddView(smLbl6,10dip,50dip,100%x-5dip,20dip)
    pnl3.AddView(smLbl7,10dip,65dip,100%x-5dip,20dip)
    pnl3.AddView(img2,100%x  - offset - 90dip,10dip,83dip,83dip)
    pnl3.AddView(btn4,10dip,100dip,30dip,30dip)
    sv.Panel.AddView(pnl3, 0dip, 50dip, 100%x  - offset, 170dip)
 
    Dim arrExpList(10) As ExpListViewItem
    arrExpList(0).Initialize:arrExpList(0).Expanded = False:arrExpList(0).IsParent = False:arrExpList(0).id= 0:arrExpList(0).childto= 0:
    arrExpList(1).Initialize:arrExpList(1).Expanded = False:arrExpList(1).IsParent = True:arrExpList(1).id= 1:arrExpList(1).childto= 0:arrExpList(1).Text = "My Account":arrExpList(1).icon  = ""
    arrExpList(2).Initialize:arrExpList(2).Expanded = False:arrExpList(2).IsParent = False:arrExpList(2).id= 2:arrExpList(2).childto= 1:arrExpList(2).Text = "Mobile No.":arrExpList(2).icon  = "sm_mobilepic.png"
    arrExpList(3).Initialize:arrExpList(3).Expanded = False:arrExpList(3).IsParent = False:arrExpList(3).id= 3:arrExpList(3).childto= 1:arrExpList(3).Text = "[email protected]":arrExpList(3).icon  = "sm_emailpic.png"

    arrExpList(4).Initialize:arrExpList(4).Expanded = False:arrExpList(4).IsParent = True:arrExpList(4).id= 4:arrExpList(4).childto= 0:arrExpList(4).Text = "My Profile":arrExpList(4).icon  = "sm_myprofile.png"
    arrExpList(5).Initialize:arrExpList(5).Expanded = False:arrExpList(5).IsParent = False:arrExpList(5).id= 5:arrExpList(5).childto= 4:arrExpList(5).Text = "Change MPIN":arrExpList(5).icon  = "sm_changepin.png"
    arrExpList(6).Initialize:arrExpList(6).Expanded = False:arrExpList(6).IsParent = False:arrExpList(6).id= 6:arrExpList(6).childto= 4:arrExpList(6).Text = "Sign Out":arrExpList(6).icon  = "sm_logout.png"

    arrExpList(7).Initialize:arrExpList(7).Expanded = False:arrExpList(7).IsParent = True:arrExpList(7).id= 7:arrExpList(7).childto= 0:arrExpList(7).Text = "Transactions":arrExpList(7).icon  = ""
    arrExpList(8).Initialize:arrExpList(8).Expanded = False:arrExpList(8).IsParent = False:arrExpList(8).id= 8:arrExpList(8).childto=7:arrExpList(8).Text = "Transaction Report":arrExpList(8).icon  = "sm_transactrpt.png"
    arrExpList(9).Initialize:arrExpList(9).Expanded = False:arrExpList(9).IsParent = False:arrExpList(9).id= 9:arrExpList(9).childto= 7:arrExpList(9).Text = "Summary":arrExpList(9).icon  = "sm_summary.png"

    clsExpList.Initialize(sv.Panel, arrExpList,DipToCurrent(15dip),offset)

I think im having a problem with my last line in DipToCurrent(15dip) because even if i change the value the results are different for the different layout

Also using clsExpList (which is my ExpandedListView), i add the views into my scrollview panel (sv.Panel)
 

Attachments

  • 2.jpg
    2.jpg
    55.1 KB · Views: 344
  • 1.jpg
    1.jpg
    54.3 KB · Views: 329

phukol

Active Member
Licensed User
Longtime User
I solved it, I was stupid and didnt see that the ExpandedListview provides the initial height of the scrollview. i just adjusted its value
 
Upvote 0
Top