use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project NiceMusic by lizixian18.
the class BannerLayout method initView.
protected void initView(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecyclerViewBannerBase);
showIndicator = a.getBoolean(R.styleable.RecyclerViewBannerBase_showIndicator, true);
autoPlayDuration = a.getInt(R.styleable.RecyclerViewBannerBase_interval, 10000);
isAutoPlaying = a.getBoolean(R.styleable.RecyclerViewBannerBase_autoPlaying, true);
mSelectedDrawable = a.getDrawable(R.styleable.RecyclerViewBannerBase_indicatorSelectedSrc);
mUnselectedDrawable = a.getDrawable(R.styleable.RecyclerViewBannerBase_indicatorUnselectedSrc);
if (mSelectedDrawable == null) {
// 绘制默认选中状态图形
GradientDrawable selectedGradientDrawable = new GradientDrawable();
selectedGradientDrawable.setShape(GradientDrawable.OVAL);
selectedGradientDrawable.setColor(getColor(R.color.colorAccent));
selectedGradientDrawable.setSize(dp2px(5), dp2px(5));
selectedGradientDrawable.setCornerRadius(dp2px(5) / 2);
mSelectedDrawable = new LayerDrawable(new Drawable[] { selectedGradientDrawable });
}
if (mUnselectedDrawable == null) {
// 绘制默认未选中状态图形
GradientDrawable unSelectedGradientDrawable = new GradientDrawable();
unSelectedGradientDrawable.setShape(GradientDrawable.OVAL);
unSelectedGradientDrawable.setColor(getColor(R.color.colorPrimaryDark));
unSelectedGradientDrawable.setSize(dp2px(5), dp2px(5));
unSelectedGradientDrawable.setCornerRadius(dp2px(5) / 2);
mUnselectedDrawable = new LayerDrawable(new Drawable[] { unSelectedGradientDrawable });
}
indicatorMargin = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorSpace, dp2px(4));
int marginLeft = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorMarginLeft, dp2px(16));
int marginRight = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorMarginRight, dp2px(0));
int marginBottom = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorMarginBottom, dp2px(11));
int g = a.getInt(R.styleable.RecyclerViewBannerBase_indicatorGravity, 0);
int gravity;
if (g == 0) {
gravity = GravityCompat.START;
} else if (g == 2) {
gravity = GravityCompat.END;
} else {
gravity = Gravity.CENTER;
}
int o = a.getInt(R.styleable.RecyclerViewBannerBase_orientation, 0);
int orientation = 0;
if (o == 0) {
orientation = OrientationHelper.HORIZONTAL;
} else if (o == 1) {
orientation = OrientationHelper.VERTICAL;
}
a.recycle();
// recyclerView部分
mRecyclerView = new RecyclerView(context);
LayoutParams vpLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
addView(mRecyclerView, vpLayoutParams);
mLayoutManager = new BannerLayoutManager(getContext(), orientation);
mRecyclerView.setLayoutManager(mLayoutManager);
new PagerSnapHelper().attachToRecyclerView(mRecyclerView);
// 指示器部分
indicatorContainer = new RecyclerView(context);
LinearLayoutManager indicatorLayoutManager = new LinearLayoutManager(context, orientation, false);
indicatorContainer.setLayoutManager(indicatorLayoutManager);
indicatorAdapter = new IndicatorAdapter();
indicatorContainer.setAdapter(indicatorAdapter);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM | gravity;
params.setMargins(marginLeft, 0, marginRight, marginBottom);
addView(indicatorContainer, params);
if (!showIndicator) {
indicatorContainer.setVisibility(GONE);
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project MTweaks-KernelAdiutorMOD by morogoku.
the class CardView method refresh.
@Override
protected void refresh() {
super.refresh();
if (mTitle != null) {
if (mTitleText != null) {
mTitle.setText(mTitleText);
mTitleParent.setVisibility(View.VISIBLE);
if (mLayoutParent != null) {
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mLayout.getLayoutParams();
layoutParams.topMargin = -mLayout.getPaddingLeft();
mLayout.requestLayout();
mLayout.setPadding(mLayout.getPaddingLeft(), 0, mLayout.getPaddingRight(), mLayout.getPaddingBottom());
}
} else {
mTitleParent.setVisibility(View.GONE);
}
}
if (mMenuButton != null && mOnMenuListener != null) {
mMenuButton.setVisibility(View.VISIBLE);
mPopupMenu = new PopupMenu(mMenuButton.getContext(), mMenuButton);
mOnMenuListener.onMenuReady(this, mPopupMenu);
}
if (mRootView != null && getOnItemClickListener() != null) {
mRootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getOnItemClickListener().onClick(CardView.this);
}
});
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project weiui by kuaifan.
the class RecycleViewDivider method drawHorizontal.
// 绘制横向 item 分割线
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getMeasuredWidth() - parent.getPaddingRight();
final int childSize = parent.getChildCount();
for (int i = 0; i < childSize; i++) {
final View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getBottom() + layoutParams.bottomMargin;
final int bottom = top + mDividerHeight;
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project weiui by kuaifan.
the class RecycleViewDivider method drawVertical.
// 绘制纵向 item 分割线
private void drawVertical(Canvas canvas, RecyclerView parent) {
final int top = parent.getPaddingTop();
final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
final int childSize = parent.getChildCount();
for (int i = 0; i < childSize; i++) {
final View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int left = child.getRight() + layoutParams.rightMargin;
final int right = left + mDividerHeight;
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project PageRecyclerView by ckrgithub.
the class PageView method initView.
private void initView() {
View inflate;
if (orientation == 0) {
inflate = View.inflate(getContext(), R.layout.horizontal_page_view, null);
} else {
inflate = View.inflate(getContext(), R.layout.vertical_page_view, null);
}
// <editor-fold desc="init recyclerView">
recyclerView = (PageRecyclerView) inflate.findViewById(R.id.recyclerView);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) recyclerView.getLayoutParams();
if (orientation == OnPageDataListener.HORIZONTAL) {
if (!overlapStyle) {
params.bottomMargin = indicatorContainerHeight;
}
} else if (orientation == OnPageDataListener.VERTICAL) {
if (!overlapStyle) {
params.leftMargin = indicatorContainerWidth;
}
}
recyclerView.setLayoutParams(params);
recyclerView.setOrientation(orientation);
recyclerView.setLooping(isLooping);
recyclerView.addOnPageChangeListener(this);
if (pageBackground != null) {
if (Build.VERSION_CODES.JELLY_BEAN <= Build.VERSION.SDK_INT) {
recyclerView.setBackground(pageBackground);
} else {
recyclerView.setBackgroundDrawable(pageBackground);
}
pageBackground = null;
}
// </editor-fold>
View indicatorContainer = inflate.findViewById(R.id.indicatorContainer);
if (hideIndicator) {
indicatorContainer.setVisibility(GONE);
} else {
// <editor-fold desc="init indicatorContainer"
params = (FrameLayout.LayoutParams) indicatorContainer.getLayoutParams();
if (orientation == OnPageDataListener.HORIZONTAL) {
params.height = indicatorContainerHeight;
} else if (orientation == OnPageDataListener.VERTICAL) {
params.width = indicatorContainerWidth;
}
indicatorContainer.setLayoutParams(params);
if (indicatorContainerBackground != null) {
if (Build.VERSION_CODES.JELLY_BEAN <= Build.VERSION.SDK_INT) {
indicatorContainer.setBackground(indicatorContainerBackground);
} else {
indicatorContainer.setBackgroundDrawable(indicatorContainerBackground);
}
indicatorContainerBackground = null;
}
// </editor-fold>
layoutIndicatorGroup(inflate);
// <editor-fold desc="init moveIndicator"
moveIndicator = inflate.findViewById(R.id.moveIndicator);
LayoutParams layoutParams = (LayoutParams) moveIndicator.getLayoutParams();
layoutParams.width = selectedIndicatorDiameter;
layoutParams.height = selectedIndicatorDiameter;
moveIndicator.setLayoutParams(layoutParams);
if (selectedIndicatorDrawable == null) {
drawViewBackground(moveIndicator, selectedIndicatorColor, selectedIndicatorDiameter, selectedIndicatorDiameter, selectedIndicatorDiameter, selectedIndicatorDiameter, 0, 0);
} else {
if (Build.VERSION_CODES.JELLY_BEAN <= Build.VERSION.SDK_INT) {
moveIndicator.setBackground(selectedIndicatorDrawable);
} else {
moveIndicator.setBackgroundDrawable(selectedIndicatorDrawable);
}
selectedIndicatorDrawable = null;
}
// </editor-fold>
}
addView(inflate);
}
Aggregations