Custom Dialog - can't get the layout right

YoungOne

New Member
Licensed User
Longtime User
First, thank you for this great forum and great community. You've helped me to go from beginner to an almost "finished" app in no time.

Now for my current problem. I must be doing something wrong but I can't figure out what. I am using the CustomDialog2 function to create a dialog with an EditText and a Spinner. When I run it on my phone (a droid 3) it doesn't look perfect yet, but it looks OK. However, when I run it on my wife's phone (Droid Razr M) it looks horrible.

If you look at my 2 pics, the first shows the problem. See how the edit text is off both the right and left side. The second pic shows my phone. Notice how there is a nice border around the panel and the edittext only runs off the right side. Running off the right side isn't right either, but at least a little better. Somehow I'm not getting the sizing right. I'm trying to size it as a percentage. Can you help? Thank you for any help you can give.

B4X:
Sub AddItem_Click
   Dim ret As Int
   Dim unitId As Int
   Log("Add Item")
      Dim cd As CustomDialog2
      Dim pnl As Panel
      pnl.Initialize("pnl")
   Dim edtAddItemName As EditText
   Dim spnAddItemUnits As Spinner
   
   edtAddItemName.Initialize("edtAddItemName")
   spnAddItemUnits.Initialize("spnAddItemUnits")
   If (100%x>100%y) Then 'landscape
      cd.AddView(pnl,80%x,60%y)
      
   Else 'portrait
      cd.AddView(pnl,80%x,30%y)
   End If
   pnl.Color=UI.clrBack
   edtAddItemName.Color=UI.edtColor
   edtAddItemName.TextColor=UI.edtTextColor
   edtAddItemName.Hint="Item Name"
   edtAddItemName.ForceDoneButton=True
   
   spnAddItemUnits.Color=UI.edtColor
   spnAddItemUnits.TextColor=UI.clrFore

   
   
   pnl.AddView(edtAddItemName,UI.marginLeft,UI.offsetTop,100%x-(2*UI.marginLeft),UI.edtHeight)
   pnl.AddView(spnAddItemUnits,UI.marginLeft,UI.offsetTop+UI.edtHeight+UI.offsetTop,100%x-(2*UI.marginLeft),UI.edtHeight)
   
   
      ' fill the units spinner
   dbutils.ExecuteSpinner(SQL1,"select name from unit order by name COLLATE NOCASE",Null,0,spnAddItemUnits)


   ret = cd.Show("", "Ok", "Cancel","OK+Add Entry",  Null)
 

Attachments

  • pic2.png
    pic2.png
    13.2 KB · Views: 226
  • pic4.png
    pic4.png
    79.6 KB · Views: 211
Top