Giter Site home page Giter Site logo

leanback_tv_widget's Introduction

#LeanBack

输入图片说明

优化记录

特点

修改自 Lenaback源码.

一个适用于Android TV端的分页加载列表库,控件继承自RecyclerView,部分源码抽取自Google Support v17 Leanback包下源码,可兼容低版本环境。相比原始的RecyclerView,拥有以下特点

1.自动回焦至被选中的item;

2.item滚动居中;

3.焦点移动至边界位置时不会出现越界丢失焦点;

4.快速滑动和慢速滑动都不会出现丢焦现象;

5.支持分页加载;

6.支持移动边框.

7.支持多个垂直滚动.

源码分析

移动在中间分析

Leanaback GridViewLayoutManger.java 滚动在中间的分析

具体流程:

GridLayoutManager.java --> onRequestChildFocus ----> scrollToView ----> scrollGrid ----> mBaseGridView.scrollBy(scrollX, scrollY);

由于多个垂直,控件的父布局设置 tag="other"后,跑的流程不一样.

GridLayoutManager.java --> onRequestChildFocus ----> scrollOther

还可以使用 (这个方法有局限性,少的话可以使用,多的不建议使用)

ItemAlignmentFacet facet = new ItemAlignmentFacet();

ItemAlignmentFacet.ItemAlignmentDef alignDef1 = new ItemAlignmentFacet.ItemAlignmentDef();

facet.setAlignmentDefs(defs);

mRowPresenter.setFacet(ItemAlignmentFacet.class, facet);

一行高亮分析

ItemBridgeAdapter 设置监听事件.

ItemBridgeAdapter.AdapterListener mBridgeAdapterListener =

new ItemBridgeAdapter.AdapterListener() {

public void onCreate(ItemBridgeAdapter.ViewHolder viewHolder) {
setRowViewSelected(vh, false);
}

};
void setRowViewSelected(ViewHolder vh, boolean selected) {
((RowPresenter)vh.getPresenter()).setRowViewSelected(vh.getViewHolder(), selected);
}

leanback_tv_widget's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.