ControlBarpublic class ControlBar extends android.widget.LinearLayout
Fields Summary |
---|
private int | mChildMarginFromCenter | private OnChildFocusedListener | mOnChildFocusedListener |
Methods Summary |
---|
protected void | onMeasure(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 void | requestChildFocus(android.view.View child, android.view.View focused)
super.requestChildFocus(child, focused);
if (mOnChildFocusedListener != null) {
mOnChildFocusedListener.onChildFocusedListener(child, focused);
}
| public boolean | requestFocus(int direction, android.graphics.Rect previouslyFocusedRect)
if (getChildCount() > 0) {
if (getChildAt(getChildCount() / 2).requestFocus(direction, previouslyFocusedRect)) {
return true;
}
}
return super.requestFocus(direction, previouslyFocusedRect);
| public void | setChildMarginFromCenter(int marginFromCenter)
mChildMarginFromCenter = marginFromCenter;
| public void | setOnChildFocusedListener(android.support.v17.leanback.widget.ControlBar$OnChildFocusedListener listener)
mOnChildFocusedListener = listener;
|
|