在android tv中更改所选项目的缩放以进行browsefragment

时间:2015-11-10 16:00:49

标签: android menuitem selected television leanback

我想更改TV元素的BrowseFragment所选元素的缩放值。 可能吗?或者在browsefragment中使用硬编码缩放操作系统?

1 个答案:

答案 0 :(得分:4)

以下是更改卡片缩放系数的方法。在MainFragment / RowsFragment中,您必须使用ListRowPresenter。你可以这样初始化它。

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

在这里你可以改变FocusHighlight Factor你会发现许多其他值,或者你可以根据你的要求选择任何值。这些是值。

ZOOM_FACTOR_MEDIUM ZOOM_FACTOR_SMALL ZOOM_FACTOR_XSMALL , 的 ZOOM_FACTOR_NONE

如果您在第二个参数中传递 false ,则可以删除所有网格上的暗光效果。你可以玩。你可以使用其他一些可能的功能

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

默认情况下,库中的 true

如果您想自定义leanback的 RowsFragment BrowseFragment 的设计,那么只需抓住它的 XML 文件,您就可以使用它的设计了。你可以把自己的实现。这只是一个想法,你如何也可以自定义leanback的其他片段。

以下是 RowsFragment 的布局我已经更改了一些颜色以便您可以理解请将其保存在res目录下的布局中,其名称为“ lb_rows_fragment.xml ”,别忘了像我说的那样命名。

<?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>