Android Question Programmatically resize TimeDialog

JGiunta

Member
Hello!
When i use the TimeDialog class from the Dialogs2 library (from @agraham ).
Is there a way to programmatically increase the size of the clock based on the device's screen?

Thank you for your time.
 

JGiunta

Member
Thank you DonManfred,

I found out an alternative route to resizing the dialog:
Make my "own" dialog and resize that

For anyone who might be looking for it:
(P.S. - It's ugly)

This is my XML
picker.xml:
    <TimePicker
    xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/time_picker"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:tag="time_picker"
        android:gravity="center"
        />

This is my B4A Show sub
Show Sub:
Sub Show ()
    If PannelloConferma.IsInitialized = True Then    ' Check if the Panel is already initialized
        PannelloConferma.RemoveAllViews                ' In case it is, we clear it
    End If

    PannelloConferma.Initialize("PannelloConferma")    ' Initialize the panel
    PannelloConferma.Tag="PannelloConferma"            ' Tag the Panel
    PannelloConferma.Color = Colors.Transparent        ' Make the Panel transparent
    act.AddView(PannelloConferma,0%x,0%y,100%x,100%y)' Add the panel to the Activity

    pnlSoloPicker.Initialize("")                    'Initialize a second panel where we will put our TimePicker
   
    'Declaring, initializing and placing the labels and panels
    Dim lblOk As Label                              
    Dim lblcancel As Label
    lblOk.Initialize("lblok")
    lblcancel.Initialize("lblcancel")
       
    PannelloConferma.AddView(pnlSoloPicker,PannelloConferma.Width*0.1,PannelloConferma.Height*0.1,PannelloConferma.Width*0.8,PannelloConferma.Height*0.8)
    PannelloConferma.AddView(lblOk,PannelloConferma.Width*0.5,PannelloConferma.Height*0.9,PannelloConferma.Width*0.1,PannelloConferma.Height * 0.05)
    PannelloConferma.AddView(lblcancel,PannelloConferma.Width*0.6,PannelloConferma.Height *0.9,PannelloConferma.Width*0.1,PannelloConferma.Height * 0.05)
   
    LayoutBuilder.LoadXmlLayout(pnlSoloPicker, "picker")    'We build the XML in the second panel
    End Sub

This is my resize sub
Resize sub:
Sub Scala(factor As Float)
    Dim jo As JavaObject = pnlSoloPicker.GetView(0)                    'Declare the picker as a JavaObject
    jo.RunMethod("setScaleX",Array As Object(factor))                'Scale it horizontally
    jo.RunMethod("setScaleY",Array As Object(factor))                'Scale it vertically
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…