本文整理匯總了Java中android.support.v7.widget.RecyclerView.setPadding方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.setPadding方法的具體用法?Java RecyclerView.setPadding怎麽用?Java RecyclerView.setPadding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.setPadding方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void setRecyclerView(RecyclerView recyclerView) {
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
recyclerView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
int i = getResources().getDisplayMetrics().widthPixels;
int y = DensityUtil.dp2px(getContext(), 90);
int p = DensityUtil.dp2px(getContext(), 15);
int padding = (3 * y + 2 * 3 * p + 2 * p - i) / (2 * 3);
recyclerView.setPadding(
padding,
DensityUtil.dp2px(getContext(), 8),
padding,
DensityUtil.dp2px(getContext(), 8)
);
}
示例2: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRecyclerView = new RecyclerView(getContext());
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerView.setAdapter(new SimpleAdapter());
mRecyclerView.setClipToPadding(false);
mRecyclerView.setPadding(0, 0, 0,
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
// track for determining animation direction.
mLastScrollOffsetY = dy;
}
});
return mRecyclerView;
}
示例3: getRecyclerViewDialog
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public static AlertDialog.Builder getRecyclerViewDialog(Context context, BaseRecyclerAdapter.OnItemClickListener listener) {
RecyclerView recyclerView = new RecyclerView(context);
RecyclerView.LayoutParams params =
new GridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
recyclerView.setPadding(Util.dipTopx(context, 16), Util.dipTopx(context, 16),
Util.dipTopx(context, 16), Util.dipTopx(context, 16));
recyclerView.setLayoutParams(params);
recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
CommentItemAdapter adapter = new CommentItemAdapter(context);
adapter.setOnItemClickListener(listener);
recyclerView.setAdapter(adapter);
recyclerView.setOverScrollMode(OVER_SCROLL_NEVER);
return getDialog(context)
.setView(recyclerView)
.setPositiveButton(null, null);
}
示例4: initPopupWindow
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 初始化顯示文件夾信息的popupWindow
*/
private void initPopupWindow() {
popRecyclerview = new RecyclerView(this);
popRecyclerview.setBackgroundColor(getResources().getColor(android.R.color.white));
LinearLayoutManager layoutManager = new LinearLayoutManager
(this, LinearLayoutManager.VERTICAL, false);
popRecyclerview.setLayoutManager(layoutManager);
popRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
popRecyclerview.setPadding(0, Commonutil.dp2px(this, 5), 0, 0);
int screenHeight = getResources().getDisplayMetrics().heightPixels;
popupWindow = new PopupWindow(popRecyclerview, ViewGroup.LayoutParams.MATCH_PARENT,
(int) (screenHeight * 0.6f));
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(false);
popupWindow.setAnimationStyle(R.style.popup_anim);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
fab.setVisibility(View.VISIBLE);
WindowManager.LayoutParams attributes =
ScanImagesActivity.this.getWindow().getAttributes();
attributes.alpha = 1;
ScanImagesActivity.this.getWindow().setAttributes(attributes);
}
});
}
示例5: initViews
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void initViews() {
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.ultimate_recycler_view_layout, this);
mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
setScrollbars();
mSwipeRefreshLayout.setEnabled(false);
if (mRecyclerView != null) {
mRecyclerView.setClipToPadding(mClipToPadding);
if (mPadding != -1.1f) {
mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
} else {
mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
}
defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
setDefaultScrollListener();
/**
* empty view setup
*/
mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
if (mEmptyId != 0) {
mEmpty.setLayoutResource(mEmptyId);
mEmptyView = mEmpty.inflate();
mEmpty.setVisibility(View.GONE);
}
/**
* floating button setup
*/
mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);
mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);
}
示例6: initViews
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void initViews() {
//super.initViews();
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.custom_recycler_view_layout, this);
mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
mSwipeRefreshLayout = null;
if (mRecyclerView != null) {
mRecyclerView.setClipToPadding(mClipToPadding);
if (mPadding != -1.1f) {
mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
} else {
mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
}
defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
setDefaultScrollListener();
mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);
mEmpty.setLayoutResource(mEmptyId);
mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);
if (mEmptyId != 0)
mEmptyView = mEmpty.inflate();
mEmpty.setVisibility(View.GONE);
if (mFloatingButtonId != 0) {
mFloatingButtonView = mFloatingButtonViewStub.inflate();
mFloatingButtonView.setVisibility(View.VISIBLE);
}
}
示例7: applyRecyclerViewPaddingForLayoutRes
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void applyRecyclerViewPaddingForLayoutRes(@NonNull RecyclerView recyclerView, @LayoutRes int res) {
int padding;
if (res == R.layout.item_grid) {
padding = (int) (getResources().getDisplayMetrics().density * 2);
} else {
padding = 0;
}
recyclerView.setPadding(padding, padding, padding, padding);
}
示例8: prepareListView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void prepareListView(Context context) {
mListView = new RecyclerView(context);
mAdapter = new ItemAdapter();
mListView.setClipToPadding(false);
mListView.setPadding(0, getResources().getDimensionPixelSize(R.dimen.stepper_margin_top), 0, 0);
mListView.addItemDecoration(new VerticalSpaceItemDecoration(
getResources().getDimensionPixelSize(R.dimen.vertical_stepper_item_space_height)));
mListView.setLayoutManager(new LinearLayoutManager(context));
mListView.setAdapter(mAdapter);
addView(mListView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
示例9: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
// Set padding for Tiles
int tilePadding = getResources().getDimensionPixelSize(R.dimen.tile_padding);
recyclerView.setPadding(tilePadding, tilePadding, tilePadding, tilePadding);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
return recyclerView;
}
示例10: MenuBottomSheetDialog
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public MenuBottomSheetDialog(@NonNull Context context) {
super(context);
RecyclerView content = new RecyclerView(context);
content.setLayoutManager(new LinearLayoutManager(context));
content.setAdapter(new ItemAdapter());
int verticalPadding = content.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_menu_vertical_margin);
content.setPadding(0, verticalPadding, 0, verticalPadding);
setContentView(content);
content.setBackgroundColor(StyledAttributesHelper.getColor(context, R.attr.colorBackgroundFloating, 0));
}
示例11: getItemOffsets
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* set the border around the View
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (parent.getPaddingLeft() != _borderSpace) {
parent.setPadding(_borderSpace, _borderSpace, _borderSpace, _borderSpace);
parent.setClipToPadding(false);
}
outRect.top = _borderSpace;
outRect.bottom = _borderSpace;
outRect.left = _borderSpace;
outRect.right = _borderSpace;
}
示例12: initRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Implement this method to customize the AbsListView
*/
protected void initRecyclerView(View view) {
mRecycler = (RecyclerView) view.findViewById(android.R.id.list);
tipView = (TextView) view.findViewById(R.id.tvTip);
setItemAnimator(null);
if (mRecycler != null) {
mRecycler.setHasFixedSize(true);
mRecycler.setClipToPadding(mClipToPadding);
mInternalOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (mExternalOnScrollListener != null)
mExternalOnScrollListener.onScrolled(recyclerView, dx, dy);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (mExternalOnScrollListener != null)
mExternalOnScrollListener.onScrollStateChanged(recyclerView, newState);
}
};
mRecycler.addOnScrollListener(mInternalOnScrollListener);
if (mPadding != -1.0f) {
mRecycler.setPadding(mPadding, mPadding, mPadding, mPadding);
} else {
mRecycler.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
if (mScrollbarStyle != -1) {
mRecycler.setScrollBarStyle(mScrollbarStyle);
}
switch (mScrollbar) {
case 0:
setVerticalScrollBarEnabled(false);
break;
case 1:
setHorizontalScrollBarEnabled(false);
break;
case 2:
setVerticalScrollBarEnabled(false);
setHorizontalScrollBarEnabled(false);
break;
}
}
}