FileDocCategorySizeDatePackage
ControlBar.javaAPI DocAndroid 5.1 API3103Thu Mar 12 22:22:56 GMT 2015android.support.v17.leanback.widget

ControlBar

public class ControlBar extends android.widget.LinearLayout

Fields Summary
private int
mChildMarginFromCenter
private OnChildFocusedListener
mOnChildFocusedListener
Constructors Summary
public ControlBar(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
public ControlBar(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);
    
Methods Summary
protected voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        if (mChildMarginFromCenter <= 0) {
            return;
        }

        int totalExtraMargin = 0;
        for (int i = 0; i < getChildCount() - 1; i++) {
            View first = getChildAt(i);
            View second = getChildAt(i+1);
            int measuredWidth = first.getMeasuredWidth() + second.getMeasuredWidth();
            int marginStart = mChildMarginFromCenter - measuredWidth / 2;
            LayoutParams lp = (LayoutParams) second.getLayoutParams();
            int extraMargin = marginStart - lp.getMarginStart();
            lp.setMarginStart(marginStart);
            second.setLayoutParams(lp);
            totalExtraMargin += extraMargin;
        }
        setMeasuredDimension(getMeasuredWidth() + totalExtraMargin, getMeasuredHeight());
    
public voidrequestChildFocus(android.view.View child, android.view.View focused)

        super.requestChildFocus(child, focused);
        if (mOnChildFocusedListener != null) {
            mOnChildFocusedListener.onChildFocusedListener(child, focused);
        }
    
public booleanrequestFocus(int direction, android.graphics.Rect previouslyFocusedRect)

        if (getChildCount() > 0) {
            if (getChildAt(getChildCount() / 2).requestFocus(direction, previouslyFocusedRect)) {
                return true;
            }
        }
        return super.requestFocus(direction, previouslyFocusedRect);
    
public voidsetChildMarginFromCenter(int marginFromCenter)

        mChildMarginFromCenter = marginFromCenter;
    
public voidsetOnChildFocusedListener(android.support.v17.leanback.widget.ControlBar$OnChildFocusedListener listener)

        mOnChildFocusedListener = listener;