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);
}
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;
}
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;
}
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);
}
}
}
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;
}
Aggregations