Video Feed Layouts (Android)

The initialization of the FwVideoFeedView

To initialize the FwVideoFeedView, the host app must call the init() function which accepts the ViewOptions instance as an optional parameter. The reason behind optional ViewOptions is the fact that you can also set the view option params in XML layout:

val videoFeedView = findViewById<FwVideoFeedView>(R.id.videoFeedView)
videoFeedView.init()

Note

The configuration passed via ViewOptions programmatically has higher priority and overrides the xml attributes.

Horizontal Layout

XML layout:

    <com.firework.videofeed.FwVideoFeedView
        android:id="@+id/videoFeedView"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        app:fw_feedLayout="horizontal"
        app:fw_feedResource="discovery"
        app:fw_feedTitleTextColor="@color/white"
        app:fw_feedTitleTextNumberOfLines="1"
        app:fw_feedTitleTextPadding="4dp"
        app:fw_feedTitleTextSize="24sp"
        app:fw_itemSpacing="12dp"
        app:fw_showFeedTitle="true" />

Programmatically:

val viewOptions = viewOptions {
    baseOptions {
        feedResource(FeedResource.Discovery)
    }
    layoutOptions {
        feedLayout(FeedLayout.HORIZONTAL)
    }
}

val videoFeedView = findViewById<FwVideoFeedView>(R.id.videoFeedView)
videoFeedView.init(viewOptions)

Vertical Layout

XML layout:

  <com.firework.videofeed.FwVideoFeedView
        android:id="@+id/videoFeedView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:fw_feedLayout="vertical"
        app:fw_feedResource="discovery"
        app:fw_feedTitleTextColor="@color/white"
        app:fw_feedTitleTextNumberOfLines="1"
        app:fw_feedTitleTextPadding="4dp"
        app:fw_feedTitleTextSize="24sp"
        app:fw_itemSpacing="12dp"
        app:fw_showFeedTitle="true" />

Programmatically:

val viewOptions = viewOptions {
    baseOptions {
        feedResource(FeedResource.Discovery)
    }
    layoutOptions {
        feedLayout(FeedLayout.VERTICAL)
    }
}

val videoFeedView = findViewById<FwVideoFeedView>(R.id.videoFeedView)
videoFeedView.init(viewOptions)

Grid Layout

XML layout:

 <com.firework.videofeed.FwVideoFeedView
        android:id="@+id/videoFeedView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:fw_feedLayout="grid"
        app:fw_columns="3"
        app:fw_feedResource="discovery"
        app:fw_feedTitleTextColor="@color/white"
        app:fw_feedTitleTextNumberOfLines="1"
        app:fw_feedTitleTextPadding="4dp"
        app:fw_feedTitleTextSize="24sp"
        app:fw_itemSpacing="12dp"
        app:fw_showFeedTitle="true" />

Programmatically:

val viewOptions = viewOptions {
    baseOptions {
        feedResource(FeedResource.Discovery)
    }
    layoutOptions {
        feedLayout(FeedLayout.GRID)
        columnCount(3)
    }
}

val videoFeedView = findViewById<FwVideoFeedView>(R.id.videoFeedView)
videoFeedView.init(viewOptions)

Last updated