Search in sources :

Example 86 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project twoway-view by lucasr.

the class BaseLayoutManager method layoutChild.

@Override
protected void layoutChild(View child, Direction direction) {
    getLaneForChild(mTempLaneInfo, child, direction);
    mLanes.getChildFrame(mChildFrame, getDecoratedMeasuredWidth(child), getDecoratedMeasuredHeight(child), mTempLaneInfo, direction);
    final ItemEntry entry = cacheChildFrame(child, mChildFrame);
    layoutDecorated(child, mChildFrame.left, mChildFrame.top, mChildFrame.right, mChildFrame.bottom);
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (!lp.isItemRemoved()) {
        pushChildFrame(entry, mChildFrame, mTempLaneInfo.startLane, getLaneSpanForChild(child), direction);
    }
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 87 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project twoway-view by lucasr.

the class TwoWayLayoutManager method makeAndAddView.

private View makeAndAddView(int position, Direction direction, Recycler recycler) {
    final View child = recycler.getViewForPosition(position);
    final boolean isItemRemoved = ((LayoutParams) child.getLayoutParams()).isItemRemoved();
    if (!isItemRemoved) {
        addView(child, (direction == Direction.END ? -1 : 0));
    }
    setupChild(child, direction);
    if (!isItemRemoved) {
        updateLayoutEdgesFromNewChild(child);
    }
    return child;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 88 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project MaterialDrawer by mikepenz.

the class ContainerDrawerItem method bindView.

@Override
public void bindView(ViewHolder viewHolder, List payloads) {
    super.bindView(viewHolder, payloads);
    Context ctx = viewHolder.itemView.getContext();
    //set the identifier from the drawerItem here. It can be used to run tests
    viewHolder.itemView.setId(hashCode());
    //define how the divider should look like
    viewHolder.view.setEnabled(false);
    //make sure our view is not used in another parent
    if (mView.getParent() != null) {
        ((ViewGroup) mView.getParent()).removeView(mView);
    }
    //set the height
    if (mHeight != null) {
        RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) viewHolder.view.getLayoutParams();
        lp.height = mHeight.asPixel(ctx);
        viewHolder.view.setLayoutParams(lp);
    }
    //make sure the header view is empty
    ((ViewGroup) viewHolder.view).removeAllViews();
    int dividerHeight = 0;
    if (mDivider) {
        dividerHeight = 1;
    }
    View divider = new View(ctx);
    divider.setMinimumHeight(dividerHeight);
    divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) UIUtils.convertDpToPixel(dividerHeight, ctx));
    //depending on the position we add the view
    if (mViewPosition == Position.TOP) {
        ((ViewGroup) viewHolder.view).addView(mView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.bottomMargin = ctx.getResources().getDimensionPixelSize(R.dimen.material_drawer_padding);
        ((ViewGroup) viewHolder.view).addView(divider, layoutParams);
    } else if (mViewPosition == Position.BOTTOM) {
        layoutParams.topMargin = ctx.getResources().getDimensionPixelSize(R.dimen.material_drawer_padding);
        ((ViewGroup) viewHolder.view).addView(divider, layoutParams);
        ((ViewGroup) viewHolder.view).addView(mView);
    } else {
        ((ViewGroup) viewHolder.view).addView(mView);
    }
    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, viewHolder.itemView);
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 89 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project MaterialDrawer by mikepenz.

the class DrawerBuilder method buildForFragment.

/**
     * Build and add the DrawerBuilder to your activity
     *
     * @return
     */
public Drawer buildForFragment() {
    if (mUsed) {
        throw new RuntimeException("you must not reuse a DrawerBuilder builder");
    }
    if (mActivity == null) {
        throw new RuntimeException("please pass an activity");
    }
    if (mRootView == null) {
        throw new RuntimeException("please pass the view which should host the DrawerLayout");
    }
    //set that this builder was used. now you have to create a new one
    mUsed = true;
    // if the user has not set a drawerLayout use the default one :D
    if (mDrawerLayout == null) {
        withDrawerLayout(-1);
    }
    //set the drawer here...
    View originalContentView = mRootView.getChildAt(0);
    boolean alreadyInflated = originalContentView.getId() == R.id.materialize_root;
    //only add the new layout if it wasn't done before
    if (!alreadyInflated) {
        // remove the contentView
        mRootView.removeView(originalContentView);
    } else {
        //if it was already inflated we have to clean up again
        mRootView.removeAllViews();
    }
    //create the layoutParams to use for the contentView
    FrameLayout.LayoutParams layoutParamsContentView = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    //add the drawer
    mRootView.addView(mDrawerLayout, layoutParamsContentView);
    //set the id so we can check if it was already inflated
    mDrawerLayout.setId(R.id.materialize_root);
    //handle the navigation stuff of the ActionBarDrawerToggle and the drawer in general
    handleDrawerNavigation(mActivity, false);
    //build the view which will be set to the drawer
    Drawer result = buildView();
    // add the slider to the drawer
    mDrawerLayout.addView(originalContentView, 0);
    //define id for the sliderLayout
    mSliderLayout.setId(R.id.material_drawer_slider_layout);
    // add the slider to the drawer
    mDrawerLayout.addView(mSliderLayout, 1);
    return result;
}
Also used : FrameLayout(android.widget.FrameLayout) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 90 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project BaseRecyclerViewAdapterHelper by CymChad.

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)

Aggregations

View (android.view.View)77 RecyclerView (android.support.v7.widget.RecyclerView)67 ViewGroup (android.view.ViewGroup)21 TextView (android.widget.TextView)21 ImageView (android.widget.ImageView)13 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)12 Toolbar (android.support.v7.widget.Toolbar)9 FrameLayout (android.widget.FrameLayout)9 Rect (android.graphics.Rect)8 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)8 BindView (butterknife.BindView)8 ActionMenuView (android.support.v7.widget.ActionMenuView)7 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)6 LinearLayout (android.widget.LinearLayout)6 CollapsibleActionView (android.support.v7.view.CollapsibleActionView)5 MenuView (android.support.v7.view.menu.MenuView)5 EditText (android.widget.EditText)5 ImageView (carbon.widget.ImageView)5 TextView (carbon.widget.TextView)5 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)5