Android Question CustomLayoutDialog without padding

rraswisak

Active Member
Licensed User
Longtime User
ok, i just figure it out, no need to adjust the padding, just make the dialog color to transparent :D

from sample above link, i modify Activity_Click event to this:

B4X:
Sub Activity_Click
   Dim cd As CustomLayoutDialog
   Dim cdlg As Object = cd.ShowAsync("Choose item", "", "", "", Null, False)
   cd.SetSize(100%x, 100%y)

   Dim jo As JavaObject = cdlg
   Dim warna As ColorDrawable
   warna.Initialize(Colors.Transparent,0)
   jo.RunMethodJO("getWindow",Null).RunMethod("setBackgroundDrawable", Array(warna))

   Wait For Dialog_Ready (DialogPanel As Panel)
   DialogPanel.LoadLayout("CustomDialogLayout")
   For i = 1 To 20
       CLVDialog.AddTextItem("Item #" & i, i)
   Next
   Wait For CLVDialog_ItemClick (Index As Int, Value As Object)
   Log("Selected item: " & Value)
   cd.CloseDialog(DialogResponse.POSITIVE)
End Sub
 
Upvote 0

rraswisak

Active Member
Licensed User
Longtime User
here with small project how i show the dialog, in android 4 (emulator and real device) the dialog color still white while in android 7 the color was transparent as expected.

Thank you for your enlightment
 

Attachments

  • TransparentDialog.zip
    11.3 KB · Views: 177
  • Screenshot_2017-12-01-15-36-42.png
    Screenshot_2017-12-01-15-36-42.png
    33.4 KB · Views: 164
  • Screenshot_20180522-150411.png
    Screenshot_20180522-150411.png
    49.1 KB · Views: 163
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is not the correct way to build the dialog. You should instead set the size of the dialog to match the actual content.

SS-2018-05-23_09.40.29.png


Tips:
1. Remove the call to AutoScaleAll as the exact size is important here.
2. Code to set the dialog:
B4X:
cd.ShowAsync("", "", "", "", Null, False)
cd.SetSize(280dip + 32dip, 220dip - 14dip)
Wait For Dialog_Ready (DialogPanel As Panel)
Log(DialogPanel)
DialogPanel.LoadLayout("1")

3. The panel with the content should be at the top of the layout.
 

Attachments

  • TransparentDialog.zip
    11.3 KB · Views: 169
Upvote 0
Top