以下是更改卡片缩放系数的方法。在您的 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>