Methods Summary |
---|
protected boolean | checkLayoutParams(ViewGroup.LayoutParams p){@inheritDoc}
return p instanceof TableRow.LayoutParams;
|
protected LinearLayout.LayoutParams | generateDefaultLayoutParams()Returns a set of layout parameters with a width of
{@link android.view.ViewGroup.LayoutParams#FILL_PARENT},
a height of {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} and no spanning.
return new LayoutParams();
|
public android.widget.TableRow$LayoutParams | generateLayoutParams(android.util.AttributeSet attrs){@inheritDoc}
return new TableRow.LayoutParams(getContext(), attrs);
|
protected LinearLayout.LayoutParams | generateLayoutParams(ViewGroup.LayoutParams p){@inheritDoc}
return new LayoutParams(p);
|
int | getChildrenSkipCount(android.view.View child, int index){@inheritDoc}
LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
// when the span is 1 (default), we need to skip 0 child
return layoutParams.span - 1;
|
int[] | getColumnsWidths(int widthMeasureSpec)Measures the preferred width of each child, including its margins.
final int numColumns = getVirtualChildCount();
if (mColumnWidths == null || numColumns != mColumnWidths.length) {
mColumnWidths = new int[numColumns];
}
final int[] columnWidths = mColumnWidths;
for (int i = 0; i < numColumns; i++) {
final View child = getVirtualChildAt(i);
if (child != null && child.getVisibility() != GONE) {
final LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
if (layoutParams.span == 1) {
int spec;
switch (layoutParams.width) {
case LayoutParams.WRAP_CONTENT:
spec = getChildMeasureSpec(widthMeasureSpec, 0, LayoutParams.WRAP_CONTENT);
break;
case LayoutParams.FILL_PARENT:
spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
break;
default:
spec = MeasureSpec.makeMeasureSpec(layoutParams.width, MeasureSpec.EXACTLY);
}
child.measure(spec, spec);
final int width = child.getMeasuredWidth() + layoutParams.leftMargin +
layoutParams.rightMargin;
columnWidths[i] = width;
} else {
columnWidths[i] = 0;
}
} else {
columnWidths[i] = 0;
}
}
return columnWidths;
|
int | getLocationOffset(android.view.View child){@inheritDoc}
return ((TableRow.LayoutParams) child.getLayoutParams()).mOffset[LayoutParams.LOCATION];
|
int | getNextLocationOffset(android.view.View child){@inheritDoc}
return ((TableRow.LayoutParams) child.getLayoutParams()).mOffset[LayoutParams.LOCATION_NEXT];
|
public android.view.View | getVirtualChildAt(int i){@inheritDoc}
if (mColumnToChildIndex == null) {
mapIndexAndColumns();
}
final int deflectedIndex = mColumnToChildIndex.get(i, -1);
if (deflectedIndex != -1) {
return getChildAt(deflectedIndex);
}
return null;
|
public int | getVirtualChildCount(){@inheritDoc}
if (mColumnToChildIndex == null) {
mapIndexAndColumns();
}
return mNumColumns;
|
private void | initTableRow()
OnHierarchyChangeListener oldListener = mOnHierarchyChangeListener;
mChildrenTracker = new ChildrenTracker();
if (oldListener != null) {
mChildrenTracker.setOnHierarchyChangeListener(oldListener);
}
super.setOnHierarchyChangeListener(mChildrenTracker);
|
private void | mapIndexAndColumns()
if (mColumnToChildIndex == null) {
int virtualCount = 0;
final int count = getChildCount();
mColumnToChildIndex = new SparseIntArray();
final SparseIntArray columnToChild = mColumnToChildIndex;
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
final LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
if (layoutParams.column >= virtualCount) {
virtualCount = layoutParams.column;
}
for (int j = 0; j < layoutParams.span; j++) {
columnToChild.put(virtualCount++, i);
}
}
mNumColumns = virtualCount;
}
|
void | measureChildBeforeLayout(android.view.View child, int childIndex, int widthMeasureSpec, int totalWidth, int heightMeasureSpec, int totalHeight){@inheritDoc}
if (mConstrainedColumnWidths != null) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
int measureMode = MeasureSpec.EXACTLY;
int columnWidth = 0;
final int span = lp.span;
final int[] constrainedColumnWidths = mConstrainedColumnWidths;
for (int i = 0; i < span; i++) {
columnWidth += constrainedColumnWidths[childIndex + i];
}
final int gravity = lp.gravity;
final boolean isHorizontalGravity = Gravity.isHorizontal(gravity);
if (isHorizontalGravity) {
measureMode = MeasureSpec.AT_MOST;
}
// no need to care about padding here,
// ViewGroup.getChildMeasureSpec() would get rid of it anyway
// because of the EXACTLY measure spec we use
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
Math.max(0, columnWidth - lp.leftMargin - lp.rightMargin), measureMode
);
int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
mPaddingTop + mPaddingBottom + lp.topMargin +
lp .bottomMargin + totalHeight, lp.height);
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
if (isHorizontalGravity) {
final int childWidth = child.getMeasuredWidth();
lp.mOffset[LayoutParams.LOCATION_NEXT] = columnWidth - childWidth;
switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.LEFT:
// don't offset on X axis
break;
case Gravity.RIGHT:
lp.mOffset[LayoutParams.LOCATION] = lp.mOffset[LayoutParams.LOCATION_NEXT];
break;
case Gravity.CENTER_HORIZONTAL:
lp.mOffset[LayoutParams.LOCATION] = lp.mOffset[LayoutParams.LOCATION_NEXT] / 2;
break;
}
} else {
lp.mOffset[LayoutParams.LOCATION] = lp.mOffset[LayoutParams.LOCATION_NEXT] = 0;
}
} else {
// fail silently when column widths are not available
super.measureChildBeforeLayout(child, childIndex, widthMeasureSpec,
totalWidth, heightMeasureSpec, totalHeight);
}
|
int | measureNullChild(int childIndex){@inheritDoc}
return mConstrainedColumnWidths[childIndex];
|
protected void | onLayout(boolean changed, int l, int t, int r, int b){@inheritDoc}
// enforce horizontal layout
layoutHorizontal();
|
protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec){@inheritDoc}
// enforce horizontal layout
measureHorizontal(widthMeasureSpec, heightMeasureSpec);
|
void | setColumnCollapsed(int columnIndex, boolean collapsed)Collapses or restores a given column.
View child = getVirtualChildAt(columnIndex);
if (child != null) {
child.setVisibility(collapsed ? GONE : VISIBLE);
}
|
void | setColumnsWidthConstraints(int[] columnWidths)Sets the width of all of the columns in this row. At layout time,
this row sets a fixed width, as defined by columnWidths ,
on each child (or cell, or column.)
if (columnWidths == null || columnWidths.length < getVirtualChildCount()) {
throw new IllegalArgumentException(
"columnWidths should be >= getVirtualChildCount()");
}
mConstrainedColumnWidths = columnWidths;
|
public void | setOnHierarchyChangeListener(OnHierarchyChangeListener listener){@inheritDoc}
mChildrenTracker.setOnHierarchyChangeListener(listener);
|