Search in sources :

Example 86 with LayoutParams

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);
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 87 with LayoutParams

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);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 88 with LayoutParams

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);
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 89 with LayoutParams

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;
        }
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 90 with LayoutParams

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);
        }
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

View (android.view.View)140 RecyclerView (android.support.v7.widget.RecyclerView)127 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)38 ViewGroup (android.view.ViewGroup)33 LinearLayout (android.widget.LinearLayout)27 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)17 Paint (android.graphics.Paint)15 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 BindView (butterknife.BindView)12 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)11 Toolbar (android.support.v7.widget.Toolbar)11 Rect (android.graphics.Rect)9 EditText (android.widget.EditText)9 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)9 AdapterView (android.widget.AdapterView)8 RelativeLayout (android.widget.RelativeLayout)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7