Search in sources :

Example 46 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project Tangram-Android by alibaba.

the class BannerView method bindHeaderView.

private void bindHeaderView(BaseCell cell) {
    if (cell != null) {
        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 47 with LayoutParams

use of android.support.v7.widget.RecyclerView.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 48 with LayoutParams

use of android.support.v7.widget.RecyclerView.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 49 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project Tangram-Android by alibaba.

the class LinearScrollView method bindHeaderView.

private void bindHeaderView(BaseCell cell) {
    if (cell != null) {
        View header = getViewFromRecycler(cell);
        if (header != null) {
            header.setId(R.id.TANGRAM_BANNER_HEADER_ID);
            // 为了解决在 item 复用过程中,itemView 的 layoutParams 复用造成 layout 错误,这里要提供一个新的 layoutParams。
            LinearLayout.LayoutParams lp = new LinearLayout.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 : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayout(android.widget.LinearLayout)

Example 50 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project SmartCampus by Vegen.

the class RecyclerAdapter method onCreateViewHolder.

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == TYPE_ITEM) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_information_item, parent, false);
        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        return new ItemViewHolder(view);
    } else if (viewType == TYPE_FOOTER) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_item_foot, parent, false);
        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        return new FooterViewHolder(view);
    }
    return null;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)86 RecyclerView (android.support.v7.widget.RecyclerView)78 TextView (android.widget.TextView)24 ViewGroup (android.view.ViewGroup)23 ImageView (android.widget.ImageView)20 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)13 FrameLayout (android.widget.FrameLayout)10 Toolbar (android.support.v7.widget.Toolbar)9 Rect (android.graphics.Rect)8 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)8 LinearLayout (android.widget.LinearLayout)8 BindView (butterknife.BindView)8 ActionMenuView (android.support.v7.widget.ActionMenuView)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)6 EditText (android.widget.EditText)6 CollapsibleActionView (android.support.v7.view.CollapsibleActionView)5 MenuView (android.support.v7.view.menu.MenuView)5 ImageView (carbon.widget.ImageView)5 TextView (carbon.widget.TextView)5