use of android.support.v7.app.ActionBar.LayoutParams in project Tangram-Android by alibaba.
the class BannerView method onMeasure.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (!Float.isNaN(ratio)) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize / ratio), MeasureSpec.EXACTLY);
} else if (height > 0) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
}
mUltraViewPager.measure(widthMeasureSpec, heightMeasureSpec);
mIndicator.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int headerHeight = 0;
if (!mHeaderViewHolders.isEmpty()) {
for (int i = 0, count = mHeaderViewHolders.size(); i < count; i++) {
View header = mHeaderViewHolders.get(i).itemView;
LayoutParams lp = (LayoutParams) header.getLayoutParams();
header.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
headerHeight += header.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
}
}
int footerHeight = 0;
if (!mFooterViewHolders.isEmpty()) {
for (int i = 0, count = mFooterViewHolders.size(); i < count; i++) {
View footer = mFooterViewHolders.get(i).itemView;
LayoutParams lp = (LayoutParams) footer.getLayoutParams();
footer.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
footerHeight += footer.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
}
}
int measureWidth = mUltraViewPager.getMeasuredWidth();
int measureHeight = mUltraViewPager.getMeasuredHeight();
if (isIndicatorOutside) {
int indicatorHeight = mIndicator.getMeasuredHeight();
setMeasuredDimension(measureWidth, measureHeight + indicatorHeight + headerHeight + footerHeight);
} else {
setMeasuredDimension(measureWidth, measureHeight + headerHeight + footerHeight);
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project Tangram-Android by alibaba.
the class BannerView method bindHeaderView.
private void bindHeaderView(BaseCell cell) {
if (cell.isValid()) {
View header = getHeaderViewFromRecycler(cell);
if (header != null) {
ViewGroup.LayoutParams lp = header.getLayoutParams();
if (lp == null || !(lp instanceof LayoutParams)) {
lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
((LayoutParams) lp).topMargin = cell.style.margin[Style.MARGIN_TOP_INDEX];
((LayoutParams) lp).leftMargin = cell.style.margin[Style.MARGIN_LEFT_INDEX];
((LayoutParams) lp).bottomMargin = cell.style.margin[Style.MARGIN_BOTTOM_INDEX];
((LayoutParams) lp).rightMargin = cell.style.margin[Style.MARGIN_RIGHT_INDEX];
addView(header, lp);
}
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project Tangram-Android by alibaba.
the class BannerView method onMeasure.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (!Float.isNaN(ratio)) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize / ratio), MeasureSpec.EXACTLY);
} else if (height > 0) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
}
mUltraViewPager.measure(widthMeasureSpec, heightMeasureSpec);
mIndicator.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int headerHeight = 0;
if (!mHeaderViewHolders.isEmpty()) {
for (int i = 0, count = mHeaderViewHolders.size(); i < count; i++) {
View header = mHeaderViewHolders.get(i).itemView;
LayoutParams lp = (LayoutParams) header.getLayoutParams();
header.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
headerHeight += header.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
}
}
int footerHeight = 0;
if (!mFooterViewHolders.isEmpty()) {
for (int i = 0, count = mFooterViewHolders.size(); i < count; i++) {
View footer = mFooterViewHolders.get(i).itemView;
LayoutParams lp = (LayoutParams) footer.getLayoutParams();
footer.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
footerHeight += footer.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
}
}
int measureWidth = mUltraViewPager.getMeasuredWidth();
int measureHeight = mUltraViewPager.getMeasuredHeight();
if (isIndicatorOutside) {
int indicatorHeight = mIndicator.getMeasuredHeight();
setMeasuredDimension(measureWidth, measureHeight + indicatorHeight + headerHeight + footerHeight);
} else {
setMeasuredDimension(measureWidth, measureHeight + headerHeight + footerHeight);
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project Tangram-Android by alibaba.
the class BannerView method onLayout.
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int measureWidth = mUltraViewPager.getMeasuredWidth();
int measureHeight = mUltraViewPager.getMeasuredHeight();
int indicatorHeight = mIndicator.getMeasuredHeight();
int top = getPaddingTop();
int left = getPaddingLeft();
if (!mHeaderViewHolders.isEmpty()) {
for (int i = 0, count = mHeaderViewHolders.size(); i < count; i++) {
View header = mHeaderViewHolders.get(i).itemView;
LayoutParams lp = (LayoutParams) header.getLayoutParams();
header.layout(left + lp.leftMargin, top + lp.topMargin, header.getMeasuredWidth(), top + lp.topMargin + header.getMeasuredHeight());
top += lp.topMargin + header.getMeasuredHeight() + lp.bottomMargin;
}
}
mUltraViewPager.layout(left, top, measureWidth, top + measureHeight);
top += measureHeight;
if (isIndicatorOutside) {
mIndicator.layout(left, top, measureWidth, top + measureHeight + indicatorHeight);
top += indicatorHeight;
} else {
mIndicator.layout(left, top - indicatorHeight, measureWidth, top);
}
if (!mFooterViewHolders.isEmpty()) {
for (int i = 0, count = mFooterViewHolders.size(); i < count; i++) {
View footer = mFooterViewHolders.get(i).itemView;
LayoutParams lp = (LayoutParams) footer.getLayoutParams();
footer.layout(left + lp.leftMargin, top + lp.topMargin, footer.getMeasuredWidth(), top + lp.topMargin + footer.getMeasuredHeight());
top += +lp.topMargin + footer.getMeasuredHeight() + lp.bottomMargin;
}
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project Tangram-Android by alibaba.
the class LinearScrollView method bindHeaderView.
private void bindHeaderView(BaseCell cell) {
if (cell != null && cell.isValid()) {
View header = getViewFromRecycler(cell);
if (header != null) {
header.setId(R.id.TANGRAM_BANNER_HEADER_ID);
// 为了解决在 item 复用过程中,itemView 的 layoutParams 复用造成 layout 错误,这里要提供一个新的 layoutParams。
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.topMargin = cell.style.margin[Style.MARGIN_TOP_INDEX];
lp.leftMargin = cell.style.margin[Style.MARGIN_LEFT_INDEX];
lp.bottomMargin = cell.style.margin[Style.MARGIN_BOTTOM_INDEX];
lp.rightMargin = cell.style.margin[Style.MARGIN_RIGHT_INDEX];
addView(header, 0, lp);
}
}
}
Aggregations