1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Código para diferentes telas/smart

Discussion in 'Portuguese Forum' started by jeronimovilar, Apr 8, 2019.

  1. jeronimovilar

    jeronimovilar Member Licensed User

    Funciona para
    tablet = 976 x 600 (160), scale 1.0
    smart = 1193 x 720 (320), scale 2.0

    Mas não funciona para 2280 x 1080, scale = 2.68 (428 dpi)
    O que preciso mudar?


    Code:
    Sub GetRealSize As LayoutValues
        
    Dim lv As LayoutValues
        
    If p.SdkVersion >= 17 Then
            
    Dim ctxt As JavaObject
            ctxt.InitializeContext
            
    Dim display As JavaObject = ctxt.RunMethodJO("getSystemService"Array("window")).RunMethod("getDefaultDisplay"Null)
            
    Dim point As JavaObject
            
    point.InitializeNewInstance("android.graphics.Point"Null)
            display.RunMethod(
    "getRealSize"Array(point))
            lv.Width = 
    point.GetField("x")
            lv.Height = 
    point.GetField("y")
        
    Else
            lv.Width = 
    100%x
            lv.Height = 
    100%y
        
    End If
        lv.Scale = 
    100dip / 100
        
    Log("GETREALSIZE: "& lv.Scale)
        
    Return lv
    End Sub

    Sub Activity_WindowFocusChanged(HasFocus As Boolean)
        
    If HasFocus Then
            
    Try
                
    Dim jo As JavaObject = Activity
                Sleep(
    300)
                jo.RunMethod(
    "setSystemUiVisibility"Array As Object(5894)) '3846 - non-sticky
            Catch
                
    'Log(LastException) 'This can cause another error
            End Try 'ignore
        End If
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        LogColor("*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*x*x*x*x"Colors.green)
      
        
    Dim LY As LayoutValues
        LY = 
    GetDeviceLayoutValues  
        Activity_WindowFocusChanged(True)
        
    Dim lv As LayoutValues = GetRealSize
        
    Log(lv & " - SDK: " & p.SdkVersion)
        
    Dim jo As JavaObject = Activity
        jo.RunMethod(
    "setBottom"Array(lv.Height))
        jo.RunMethod(
    "setRight"Array(lv.Width))
        
    Activity.Height = lv.Height
        
    Activity.Width = lv.Width
      
        
    Activity.LoadLayout("test")
        
    Log(Panel1.Width & "x" & Panel1.Height)
        Button1.Initialize(
    "Button1")
        Panel1.AddView(Button1,Panel1.Left*
    1.2, Panel1.Top*1.2,Panel1.Width*0.80, Panel1.Height*0.80)
    End Sub
    [QUOTE
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice