简体   繁体   English

更改android tv中browsefragment所选项目的缩放

[英]Change zoom of selected item for browsefragment in android tv

I want to change the zoom value of selected element for BrowseFragment of TV elements.我想为 TV 元素的 BrowseFragment 更改所选元素的缩放值。 Is it possible?是否可以? or that zoom os hardcoded in browsefragment?或者在浏览片段中硬编码的缩放操作系统?

Here is how you can change zoom factor of the card. 这是更改卡的缩放倍数的方法。 In your MainFragment/RowsFragment you must be using ListRowPresenter. 在MainFragment / RowsFragment中,您必须使用ListRowPresenter。 You can initialise it this way. 您可以通过这种方式进行初始化。

ListRowPresenter presenter= new ListRowPresenter(FocusHighlight.ZOOM_FACTOR_LARGE,true);

here you can change FocusHighlight Factor you will find many other values or you can choose any per according to your requirements. 在这里,您可以更改FocusHighlight Factor,您可以找到许多其他值,或者可以根据需要选择任何值。 Here are those values. 这些是这些值。

ZOOM_FACTOR_MEDIUM , ZOOM_FACTOR_SMALL , ZOOM_FACTOR_XSMALL , ZOOM_FACTOR_NONE ZOOM_FACTOR_MEDIUMZOOM_FACTOR_SMALLZOOM_FACTOR_XSMALLZOOM_FACTOR_NONE

if you pass false in second parameter then you can remove dim light effect on all grids. 如果在第二个参数中传递false ,则可以消除所有网格上的暗光效果。 You can just play around.Here are some other possible functions you can use 您可以随便玩玩,这里还有其他一些可能的功能可以使用

    presenter.setShadowEnabled(false);
    presenter.enableChildRoundedCorners(false);
    presenter.setSelectEffectEnabled(false);
    presenter.setKeepChildForeground(false);

these are by default true in the library. 这些在库中默认为true

if you want to customise design of leanback's RowsFragment or BrowseFragment then just grab it's XML file and you can play around with its design. 如果您想自定义leanback的RowsFragmentBrowseFragment的设计,则只需获取它的XML文件,然后就可以进行设计。 You can put your own implementation. 您可以放置​​自己的实现。 This is just an idea to that how you can also customise other fragments of leanback. 这只是您还可以自定义leanback其他片段的一个想法。

Here is the layout of RowsFragment I have changed some colours so you can understand please save it in your layouts under res directory with this name " lb_rows_fragment.xml ", don't forget to name it as I have said. 这是RowsFragment的布局,我已经更改了一些颜色,因此您可以理解,请使用“ lb_rows_fragment.xml ”将其保存在res目录下的布局中,不要忘了像我所说的那样命名。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:id="@+id/descriptions_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/main_screen_prog_desc_height"
    >

    <RelativeLayout
        android:id="@+id/description_parent_view"
        android:layout_width="@dimen/main_screen_prog_desc_width"
        android:layout_height="wrap_content"
        >
<!--you can add description etc here or any other stuff. whatever you like. -->
</RelativeLayout>

<android.support.v17.leanback.widget.ScaleFrameLayout
    android:id="@+id/scale_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/descriptions_layout"
    android:background="#fff"
    android:layout_marginRight="170dp">

    <android.support.v17.leanback.widget.VerticalGridView
        android:id="@+id/container_list"
        style="?attr/rowsVerticalGridStyle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#45f"
        android:clipToPadding="false"/>

</android.support.v17.leanback.widget.ScaleFrameLayout>

Yes, You can change zoom factor of the card:是的,您可以更改卡的缩放系数:

One way is above mention the answer: using zoom factor一种方法是上面提到的答案:使用缩放因子

 val listRowPresenter = ListRowPresenter(ZOOM_FACTOR_LARGE)

Second way is to change the fraction value of ZOOM_FACTOR from the dimen.xml file.第二种方法是从 dimen.xml 文件中更改 ZOOM_FACTOR 的分数值。

Here is default fraction value for all, you can customize based on your need这是所有的默认分数值,您可以根据需要自定义

<item name="lb_focus_zoom_factor_xsmall" type="fraction">106%</item>
<item name="lb_focus_zoom_factor_small" type="fraction">110%</item>
<item name="lb_focus_zoom_factor_medium" type="fraction">114%</item>
<item name="lb_focus_zoom_factor_large" type="fraction">118%</item>

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

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