Android Question [Solution] DetailsDialog.SetSize - how to change to full size?

T201016

Active Member
Licensed User
Longtime User
Hi,
Attempting to resize the dialog box to the size of the full screen ends with the result as shown in the picture:

Settings:
DialogWidthInside = 100% x
DialogHeightInside = 100% y

The "SetSize" method is not working properly for me. What could be the reason?

DetailsDialog.SetSize(DialogWidthInside, DialogHeightInside):
Sub Input(InputParameters As Map, DialogWidthInside As Int, DialogHeightInside As Int, isEncrypt As Boolean) As ResumableSub
    Dim EditorHeight As Int = DialogHeightInside - (3 * 48dip)
    Dim ico As B4XBitmap = LoadBitmap(File.DirAssets, "3.png")

    Dim sf As Object = DetailsDialog.ShowAsync(InputParameters.Get("title"), InputParameters.Get("positive"), InputParameters.Get("cancel"), "", ico, False)
    DetailsDialog.SetSize(DialogWidthInside, DialogHeightInside)
    isEncryptFile = isEncrypt
    Wait For (sf) Dialog_Ready(Dialogpanel As Panel)
  
    ...
 

Attachments

  • Screenshot_20220502-172747.png
    Screenshot_20220502-172747.png
    73.4 KB · Views: 97
Last edited:
Solution
Welcome back,
just managed to fix my problem with below code:

Also, thank you for your quick response and support :)
Regards.


Resize::
Dim jo As JavaObject = sf
Dim cd As ColorDrawable
cd.Initialize2(Colors.White, 4dip, 1dip, Colors.ARGB(45,0,0,0))
jo.RunMethodJO("getWindow", Null).RunMethod("setBackgroundDrawable", Array(cd))
        
Dim jo As JavaObject = sf
Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
Dim lp As JavaObject = window.RunMethod("getAttributes", Null)
lp.SetField("gravity", Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL))
lp.SetField("y", 0dip) 'set the top position
window.RunMethod("setAttributes", Array(lp))
Wait For (sf) Dialog_Result (Res As Int)

T201016

Active Member
Licensed User
Longtime User
Welcome back,
just managed to fix my problem with below code:

Also, thank you for your quick response and support :)
Regards.


Resize::
Dim jo As JavaObject = sf
Dim cd As ColorDrawable
cd.Initialize2(Colors.White, 4dip, 1dip, Colors.ARGB(45,0,0,0))
jo.RunMethodJO("getWindow", Null).RunMethod("setBackgroundDrawable", Array(cd))
        
Dim jo As JavaObject = sf
Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
Dim lp As JavaObject = window.RunMethod("getAttributes", Null)
lp.SetField("gravity", Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL))
lp.SetField("y", 0dip) 'set the top position
window.RunMethod("setAttributes", Array(lp))
Wait For (sf) Dialog_Result (Res As Int)
 
Upvote 0
Solution
Top