Search in sources :

Example 66 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project PageRecyclerView by ckrgithub.

the class PageView method layoutIndicatorGroup.

private void layoutIndicatorGroup(View inflate) {
    indicatorGroup = (LinearLayout) inflate.findViewById(R.id.indicatorGroup);
    View view = inflate.findViewById(R.id.relativeLayout);
    LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
    layoutParams.setMargins(indicatorGroupMarginLeft, indicatorGroupMarginTop, indicatorGroupMarginRight, indicatorGroupMarginBottom);
    final int verticalGravity = indicatorGroupAlignment & Gravity.VERTICAL_GRAVITY_MASK;
    int horizontalGravity = indicatorGroupAlignment & Gravity.HORIZONTAL_GRAVITY_MASK;
    Logd(TAG, "initView: indicatorGroupAlignment:" + indicatorGroupAlignment + ",verticalGravity:" + verticalGravity + ",horizontalGravity:" + horizontalGravity);
    switch(horizontalGravity) {
        case Gravity.CENTER_HORIZONTAL:
            layoutParams.addRule(CENTER_HORIZONTAL);
            break;
        case Gravity.RIGHT:
            // layoutParams.addRule(ALIGN_PARENT_RIGHT);.tell me why it doesn't work ?
            layoutParams.addRule(ALIGN_PARENT_END);
        case Gravity.LEFT:
        default:
            layoutParams.addRule(ALIGN_PARENT_LEFT);
            break;
    }
    switch(verticalGravity) {
        case Gravity.CENTER_VERTICAL:
            layoutParams.addRule(CENTER_VERTICAL);
            break;
        case Gravity.BOTTOM:
            layoutParams.addRule(ALIGN_PARENT_BOTTOM);
            break;
        case Gravity.TOP:
        default:
            layoutParams.addRule(ALIGN_PARENT_TOP);
            break;
    }
    view.setLayoutParams(layoutParams);
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 67 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project BaseProject by feer921.

the class BaseQuickAdapter method addFooterView.

/**
 * Add footer view to mFooterLayout and set footer view position in mFooterLayout.
 * When index = -1 or index >= child count in mFooterLayout,
 * the effect of this method is the same as that of {@link #addFooterView(View)}.
 *
 * @param footer
 * @param index  the position in mFooterLayout of this footer.
 *               When index = -1 or index >= child count in mFooterLayout,
 *               the effect of this method is the same as that of {@link #addFooterView(View)}.
 */
public int addFooterView(View footer, int index, int orientation) {
    if (mFooterLayout == null) {
        mFooterLayout = new LinearLayout(footer.getContext());
        if (orientation == LinearLayout.VERTICAL) {
            mFooterLayout.setOrientation(LinearLayout.VERTICAL);
            mFooterLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
        } else {
            mFooterLayout.setOrientation(LinearLayout.HORIZONTAL);
            mFooterLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
        }
    }
    final int childCount = mFooterLayout.getChildCount();
    if (index < 0 || index > childCount) {
        index = childCount;
    }
    mFooterLayout.addView(footer, index);
    if (mFooterLayout.getChildCount() == 1) {
        int position = getFooterViewPosition();
        if (position != -1) {
            notifyItemInserted(position);
        }
    }
    return index;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) LinearLayout(android.widget.LinearLayout) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 68 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project BaseProject by feer921.

the class BaseQuickAdapter method addHeaderView.

/**
 * @param header
 * @param index
 * @param orientation
 */
public int addHeaderView(View header, int index, int orientation) {
    if (mHeaderLayout == null) {
        mHeaderLayout = new LinearLayout(header.getContext());
        if (orientation == LinearLayout.VERTICAL) {
            mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
            mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
        } else {
            mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
            mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
        }
    }
    final int childCount = mHeaderLayout.getChildCount();
    if (index < 0 || index > childCount) {
        index = childCount;
    }
    mHeaderLayout.addView(header, index);
    if (mHeaderLayout.getChildCount() == 1) {
        int position = getHeaderViewPosition();
        if (position != -1) {
            notifyItemInserted(position);
        }
    }
    return index;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) LinearLayout(android.widget.LinearLayout) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 69 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project BaseProject by feer921.

the class BaseQuickAdapter method setEmptyView.

public void setEmptyView(View emptyView) {
    boolean insert = false;
    if (mEmptyLayout == null) {
        mEmptyLayout = new FrameLayout(emptyView.getContext());
        final LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        final ViewGroup.LayoutParams lp = emptyView.getLayoutParams();
        if (lp != null) {
            layoutParams.width = lp.width;
            layoutParams.height = lp.height;
        }
        mEmptyLayout.setLayoutParams(layoutParams);
        insert = true;
    }
    mEmptyLayout.removeAllViews();
    mEmptyLayout.addView(emptyView);
    mIsUseEmpty = true;
    if (insert) {
        if (getEmptyViewCount() == 1) {
            int position = 0;
            if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
                position++;
            }
            notifyItemInserted(position);
        }
    }
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 70 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project AgileDev by LZ9.

the class ItemDecorationTestActivity method getExpandView.

/**
 * 获取扩展view
 */
private View getExpandView() {
    LinearLayout linearLayout = new LinearLayout(getContext());
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(layoutParams);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    // 方向
    final TextView orientationTv = getTextView(R.string.drag_orientation);
    orientationTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showOrientationPopupWindow(v);
        }
    });
    linearLayout.addView(orientationTv, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    // 布局
    final TextView LayoutManagerTv = getTextView(R.string.drag_layout_manager);
    LayoutManagerTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showLayoutManagerPopupWindow(v);
        }
    });
    linearLayout.addView(LayoutManagerTv, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    return linearLayout;
}
Also used : TextView(android.widget.TextView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Aggregations

View (android.view.View)138 RecyclerView (android.support.v7.widget.RecyclerView)128 TextView (android.widget.TextView)52 ImageView (android.widget.ImageView)36 LinearLayout (android.widget.LinearLayout)32 ViewGroup (android.view.ViewGroup)31 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)16 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)13 Paint (android.graphics.Paint)12 RelativeLayout (android.widget.RelativeLayout)12 BindView (butterknife.BindView)12 Rect (android.graphics.Rect)11 Toolbar (android.support.v7.widget.Toolbar)11 EditText (android.widget.EditText)10 DialogInterface (android.content.DialogInterface)9 Handler (android.os.Handler)9 AdapterView (android.widget.AdapterView)9 Intent (android.content.Intent)8