androidandroidxandroid-tvleanbackbrowsefragment

Android and FireTv UI customization using RowsSupportFragment


I am new to Android TV development and would like to know a few things. I saw that using Leanback we can achieve this. The key components being BrowseSupportFragment, RowsSupportFragment etc.

What I want is. Currently, in BrowseSupportFragment I am using PageRow such that I can have a custom fragment (extending RowsSupportFragment) for each row. What I want is this, the custom Fragment to be a regular Fragment (extending Fragment) and have some FrameLayouts in that and for that FrameLayouts I can call different Fragments (RowsSupportFragment). So just to summarize I want something like BrowseSupportFragment --> Fragment --> RowsSupportFragment for each frameLayout in this way I can customize the UI as I want.

Can someone help me with this?


Solution

  • I couldn't get around this situation. So I ended up having normal fragments and some key important points in case any one else needs the same.

    1. android:background="?android:attr/selectableItemBackground" this to the parent layout to get the current view selected effect.
    2. Direction should be handled by onKeyListener with these events.

      a. keyCode == KeyEvent.KEYCODE_DPAD_UP

      b. keyCode == KeyEvent.KEYCODE_DPAD_DOWN

      c. keyCode == KeyEvent.KEYCODE_DPAD_LEFT

      d. keyCode == KeyEvent.KEYCODE_DPAD_RIGHT

      e. keyCode == KeyEvent.KEYCODE_DPAD_ENTER

    ( when you press enter key on the keyboard) Make sure to check event.getAction() == KeyEvent.ACTION_DOWN otherwise you will run into the problem of skipping the views in between.

    If anyone gets the correct implementation of the about question please update till then this is my solution.