Android Question Resize webviews flickers very much

Discussion in 'Android Questions' started by Alessandra Pellegri, Aug 4, 2015.

  1. Alessandra Pellegri

    Alessandra Pellegri Active Member Licensed User

    My intent is show two webviews horizontally separated buy a thin button.
    Sliding this button I should resize webviews like a splitter in Windows 7.

    I created this code:
    Code:
    #Region  Project Attributes
       
    #ApplicationLabel: B4A Example
       
    #VersionCode: 1
       
    #VersionName:
       
    'SupportedOrientations possible values: unspecified, landscape or portrait.
       #SupportedOrientations: unspecified
       
    #CanInstallToExternalStorage: False
    #End Region

    #Region  Activity Attributes
       
    #FullScreen: False
       
    #IncludeTitle: True
    #End Region

    Sub Process_Globals
       
    'These global variables will be declared once when the application starts.
       'These variables can be accessed from all modules.
       Dim wStartX, wStartY As Int
    End Sub

    Sub Globals
       
    'These global variables will be redeclared each time the activity is created.
       'These variables can only be accessed from this module.

       
    Private Button1 As Button
       
    Private WebView1 As WebView
       
    Private WebView2 As WebView
       
    Dim TouchSlop As Int
      
       
    Private Panel1 As Panel
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       
    'Do not forget to load the layout file created with the visual designer. For example:
       Activity.LoadLayout("Prima")
       
    Dim r As Reflector
       r.Target = r.RunStaticMethod(
    "android.view.ViewConfiguration""get"Array As Object(r.GetContext), Array As String("android.content.Context"))
       TouchSlop = r.RunMethod(
    "getScaledTouchSlop")  
       Button1.Height=
    30dip
       Button1.Width=Panel1.Width
       Button1.Left=
    0
       Button1.Top=Panel1.Height-Button1.Height
       WebView2.Width=Panel1.Width
       WebView2.Top=Panel1.Height
       SetOnTouchListener(Button1)
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Private Sub SetOnTouchListener(MyView As View)
       
    Dim r As Reflector
       r.Target = MyView
       r.SetOnTouchListener(
    "Content_Touch")
    End Sub

    Private Sub Content_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
       
    Select Action    
         
    Case 0
           wStartY=Y
         
    Case 2
           
    Dim MoveQty As Int = Abs(Y-wStartY)
           
    If (MoveQty>TouchSlop) Then
             Panel1.Height=Panel1.Height+Y-wStartY
             Button1.Top=Panel1.Height-Button1.Height
             WebView2.Top=Panel1.Height
             wStartY=Y
           
    End If
       
    End Select
       
    Return True
    End Sub
    WebView1 and Button1 are part of Panel1, instead WebView2 is under Activity.

    The code seems to work, but flickers very much and the button1 doesn't remain exactly locked to the finger.

    Someone could help me ?

    Thank you
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can defer the webview resizing to ACTION_UP.
     
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