240 发简信
IP属地:广东
  • 没碰到过类似问题,你可以直接看看move方法里是否监听到了按键事件,还是在外层被拦截了,可能第一次焦点没有在MetroRecyclerview上

    android tv 列表滚动控件-MetroRecyclerView

    焦点展示结合了----FlowView-https://www.jianshu.com/p/dd559bcae221 github库---demo源码-https://git...

  • @披星戴月xo 那就只能想想别的办法了

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • public static void requestViewFocus(final View view) {
    if (view.getWidth() > 0 && view.getHeight() > 0) {
    view.requestFocus();
    return;
    }
    view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

    @SuppressWarnings("deprecation")
    @Override
    public void onGlobalLayout() {
    int width = view.getWidth();
    int height = view.getHeight();
    if (width > 0 && height > 0) {
    view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
    view.setFocusable(true);
    view.requestFocus();
    }
    }
    });
    }

    这样就行了

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • @ihu11 直接在外层的layout 焦点进入的时候算出你需要的焦点位置

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • @上善若水_19df @Override
    protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
    if (previouslyFocusedRect != null) {
    if (direction == View.FOCUS_FORWARD) {
    direction = View.FOCUS_RIGHT;
    } else if (direction == View.FOCUS_BACKWARD) {
    direction = View.FOCUS_LEFT;
    }
    View nextFocus = FocusFinder.getInstance().findNextFocusFromRect(this, previouslyFocusedRect, direction);
    if (nextFocus == null) {
    return false;
    }
    boolean requestFocus = nextFocus.requestFocus(direction, previouslyFocusedRect);

    return requestFocus;
    } else {
    ViewGroup viewGroup = (ViewGroup) getChildAt(0);
    View child = null;
    if (direction == View.FOCUS_LEFT) {
    int left = 0;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
    View v = viewGroup.getChildAt(i);
    if (v.getLeft() >= left) {
    child = v;
    left = v.getLeft();
    }
    }
    } else if (direction == View.FOCUS_RIGHT) {
    int left = Integer.MAX_VALUE;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
    View v = viewGroup.getChildAt(i);
    if (v.getLeft() <= left) {
    left = v.getLeft();
    child = v;
    }
    }
    }
    if (child == null) {
    child = FocusFinder.getInstance().findNextFocus(this, null, direction);
    if (child == null) {
    return false;
    }
    }
    child.requestFocus(direction, previouslyFocusedRect);
    return true;
    }
    }

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • @上善若水_19df 首页这种切换都是用viewpager实现的吧,然后重写fragment里面layout的focusSearch(内部焦点),onRequestFocusInDescendants(外部焦点进去)方法,去确定下一个焦点

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • @上善若水_19df FlowView.setOffset

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • @上善若水_19df moveTo是可以传偏移量的,直接计算出动画的最终位置,移动的时候把偏移量带上就行了

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • @上善若水_19df 直接把飞框放到Activity的布局里,fragment直接通过getActivity()获得句柄调用就行了

    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...

  • android应用性能优化

    1. UI布局的优化 使用include,merge,ViewStub标签优化布局 尽量不存在冗余嵌套及过于复杂的布局(譬如10层布局嵌套就会异常) 尽量使用GONE替换IN...

  • android-线程管理-TaskHelper

    以前线程总是使用new Thread().start()这种方式,或者使用线程池ThreadPoolExecutor管理,但是线程池只能控制数量,无法控制逻辑,各种线程之间的...

  • 120
    android tv 列表滚动控件-MetroRecyclerView

    焦点展示结合了----FlowView-https://www.jianshu.com/p/dd559bcae221 github库---demo源码-https://git...

  • 120
    android tv 焦点移动控件-飞框-FlowView

    github库---demo源码-https://github.com/ihu11/MetroRecyclerView 1.先来一张效果图展示焦点移动控制 功能概述1、焦点框...