Java Code Examples for com.mikepenz.materialize.util.UIUtils#convertDpToPixel()
The following examples show how to use
com.mikepenz.materialize.util.UIUtils#convertDpToPixel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerDrawerItem.java From MaterialDrawer-Xamarin with Apache License 2.0 | 4 votes |
@Override public void bindView(RecyclerView.ViewHolder holder) { Context ctx = holder.itemView.getContext(); //get our viewHolder ViewHolder viewHolder = (ViewHolder) holder; //set the identifier from the drawerItem here. It can be used to run tests holder.itemView.setId(getIdentifier()); //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); } //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, holder.itemView); }