Android Question How to load two layouts on same element in XmlLayoutBuilder

ronovar

Active Member
Licensed User
Longtime User
I need to set FFMpegVideoView to scale video width and height to parent size....so i added it to frame using XmlLayoutBuilder.

I need when i press OK (FFMpegVideoView goes FullScreen) and when i press again OK (FFMpegVideoView goes SmallScreen)

I define xml layout like this:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
   
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <tv.danmaku.ijk.media.widget.VideoView
            android:id="@+id/videoViewRelative"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center" />
     </FrameLayout>
</LinearLayout>

And Code to load FFMpegVideoView is this:

B4X:
Sub Globals
    Dim FullScreen As Boolean = False
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim x As XmlLayoutBuilder
    'load the layout
    x.LoadXmlLayout(Activity, "layout1")

    FFMpegVideoView1 = x.GetView("videoViewRelative")

    FFMpegVideoView1.SetVideoPath("http://url.com/video")
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Select Case KeyCode
        Case KeyCodes.KEYCODE_DPAD_CENTER
            If (FullScreen = False) Then
                'SET - FullScreen
                FFMpegVideoView1.Width  = 100%x
                FFMpegVideoView1.Height = 100%y
                FullScreen = True
                Log("Full...")
            Else
                'SET - SmallScreen
                FFMpegVideoView1.Width  = 579dip
                FFMpegVideoView1.Height = 320dip
               
                FullScreen = False
                Log("Small...")
            End If
    End Select
End Sub

When i start apk it needs to start SmallScreen(Left: 624dip, Top: 84dip, Width: 579dip, Height: 330dip) And when OK is pressed it need to Show (Left: 0dip, Top: 0dip, Width: 100%x, Height: 100%y).

How can i set this using XmlLayoutBuilder?
 
Top