简体   繁体   English

使用 RowsSupportFragment 自定义 Android 和 FireTv UI

[英]Android and FireTv UI customization using RowsSupportFragment

I am new to Android TV development and would like to know a few things.我是 Android 电视开发的新手,想知道一些事情。 I saw that using Leanback we can achieve this.我看到使用 Leanback 我们可以实现这一点。 The key components being BrowseSupportFragment, RowsSupportFragment etc.关键组件是 BrowseSupportFragment、RowsSupportFragment 等。

What I want is.我想要的是。 Currently, in BrowseSupportFragment I am using PageRow such that I can have a custom fragment (extending RowsSupportFragment) for each row.目前,在 BrowseSupportFragment 中,我正在使用 PageRow,这样我就可以为每一行拥有一个自定义片段(扩展 RowsSupportFragment)。 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).我想要的是这个,自定义的 Fragment 是一个常规的 Fragment(扩展 Fragment),并且其中有一些 FrameLayouts,对于那个 FrameLayouts,我可以调用不同的 Fragment(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.因此,总结一下,我想要每个 frameLayout 的 BrowseSupportFragment --> Fragment --> RowsSupportFragment 之类的东西,这样我就可以根据需要自定义 UI。

Can someone help me with this?有人可以帮我弄这个吗?

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. android:background="?android:attr/selectableItemBackground"这个给父布局获取当前视图选中效果。
  2. Direction should be handled by onKeyListener with these events.方向应该由 onKeyListener 处理这些事件。

    a.一个。 keyCode == KeyEvent.KEYCODE_DPAD_UP keyCode == KeyEvent.KEYCODE_DPAD_UP

    b.湾。 keyCode == KeyEvent.KEYCODE_DPAD_DOWN keyCode == KeyEvent.KEYCODE_DPAD_DOWN

    c. c。 keyCode == KeyEvent.KEYCODE_DPAD_LEFT keyCode == KeyEvent.KEYCODE_DPAD_LEFT

    d. d。 keyCode == KeyEvent.KEYCODE_DPAD_RIGHT keyCode == KeyEvent.KEYCODE_DPAD_RIGHT

    e. e. keyCode == KeyEvent.KEYCODE_DPAD_ENTER 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. (当你按下键盘上的回车键时)确保检查 event.getAction() == KeyEvent.ACTION_DOWN 否则你会遇到跳过视图的问题。

If anyone gets the correct implementation of the about question please update till then this is my solution.如果有人得到关于问题的正确实施,请更新到那时这是我的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM