Java Code Examples for androidx.recyclerview.widget.RecyclerView#setClipToPadding()
The following examples show how to use
androidx.recyclerview.widget.RecyclerView#setClipToPadding() .
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: AbstractSettingsFragment.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@Override public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { RecyclerView rv = super.onCreateRecyclerView(inflater, parent, savedInstanceState); rv.setClipToPadding(false); rv.setFitsSystemWindows(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { rv.setOnApplyWindowInsetsListener((v, insets) -> { v.setPadding( insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom() ); return insets; }); } return rv; }
Example 2
Source File: TransitionMusicLibraryDemoFragment.java From material-components-android with Apache License 2.0 | 6 votes |
private RecyclerView createRecyclerView(boolean listTypeGrid) { Context context = requireContext(); RecyclerView recyclerView = new RecyclerView(context); recyclerView.setLayoutParams( new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); int verticalPadding = context.getResources().getDimensionPixelSize(R.dimen.album_list_padding_vertical); recyclerView.setPadding(0, verticalPadding, 0, verticalPadding); recyclerView.setClipToPadding(false); if (listTypeGrid) { recyclerView.setLayoutManager(new GridLayoutManager(context, GRID_SPAN_COUNT)); } else { recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.addItemDecoration( new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); } return recyclerView; }
Example 3
Source File: OptimumRecyclerView.java From RvHelper with Apache License 2.0 | 6 votes |
/** * Implement this method to customize the AbsListView */ protected void initRecyclerView(View view) { View recyclerView = view.findViewById(android.R.id.list); if (recyclerView instanceof RecyclerView) mRecyclerView = (RecyclerView) recyclerView; else throw new IllegalArgumentException("OptimumRecyclerview works with a RecyclerView!"); mRecyclerView.setClipToPadding(mClipToPadding); if (!FloatUtil.compareFloats(mPadding, -1.0f)) { mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding); } else { mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); } if (mScrollbarStyle != -1) { mRecyclerView.setScrollBarStyle(mScrollbarStyle); } }
Example 4
Source File: MysplashSettingsFragment.java From Mysplash with GNU Lesser General Public License v3.0 | 6 votes |
@Override public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { RecyclerView rv = super.onCreateRecyclerView(inflater, parent, savedInstanceState); rv.setClipToPadding(false); rv.setFitsSystemWindows(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { rv.setOnApplyWindowInsetsListener((v, insets) -> { v.setPadding( insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom() ); return insets; }); } return rv; }
Example 5
Source File: VerticalStepperView.java From MaterialStepperView with MIT License | 5 votes |
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)); }
Example 6
Source File: SpacesItemDecoration.java From Android-Video-Trimmer with Apache License 2.0 | 5 votes |
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getPaddingLeft() != halfSpace) { parent.setPadding(halfSpace, halfSpace, halfSpace, halfSpace); parent.setClipToPadding(false); } outRect.top = halfSpace; outRect.bottom = halfSpace; outRect.left = halfSpace; outRect.right = halfSpace; }
Example 7
Source File: GridMarginsDecoration.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
public GridMarginsDecoration(@Px float marginsVertical, @Px float marginsHorizontal, RecyclerView recyclerView) { this.marginsVertical = marginsVertical; this.marginsHorizontal = marginsHorizontal; recyclerView.setClipToPadding(false); recyclerView.setPadding( (int) marginsHorizontal / 2, (int) marginsVertical / 2, (int) marginsHorizontal / 2, (int) marginsVertical / 2 ); }
Example 8
Source File: GridMarginsItemDecoration.java From Mysplash with GNU Lesser General Public License v3.0 | 5 votes |
private void setParentPadding(RecyclerView parent, @Px int padding, Rect insets) { parent.setPadding( padding + insets.left, padding, padding + insets.right, padding + insets.bottom ); parent.setClipToPadding(false); }
Example 9
Source File: NavigationFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
@NonNull @Override public final RecyclerView onCreateRecyclerView(final LayoutInflater inflater, final ViewGroup parent, final Bundle savedInstanceState) { RecyclerView recyclerView = super.onCreateRecyclerView(inflater, parent, savedInstanceState); recyclerView.setClipToPadding(false); int paddingTop = getActivity().getResources().getDimensionPixelSize(R.dimen.list_view_padding_top); recyclerView.setPadding(recyclerView.getPaddingLeft(), paddingTop, recyclerView.getPaddingRight(), recyclerView.getPaddingBottom()); return recyclerView; }
Example 10
Source File: UltimateRecyclerView.java From UltimateRecyclerView with Apache License 2.0 | 5 votes |
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); }
Example 11
Source File: CustomUltimateRecyclerview.java From UltimateRecyclerView with Apache License 2.0 | 5 votes |
@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); } }
Example 12
Source File: BoxBrowseFolderGridFragment.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getPaddingLeft() != halfSpace) { parent.setPadding(halfSpace, halfSpace, halfSpace, halfSpace); parent.setClipToPadding(false); } outRect.top = halfSpace; outRect.bottom = halfSpace; outRect.left = halfSpace; outRect.right = halfSpace; }
Example 13
Source File: RecyclerSpec.java From litho with Apache License 2.0 | 4 votes |
@OnMount static void onMount( ComponentContext c, SectionsRecyclerView sectionsRecycler, @Prop Binder<RecyclerView> binder, @Prop(optional = true) boolean hasFixedSize, @Prop(optional = true) boolean clipToPadding, @Prop(optional = true) int leftPadding, @Prop(optional = true) int rightPadding, @Prop(optional = true) int topPadding, @Prop(optional = true) int bottomPadding, @Prop(optional = true, resType = ResType.COLOR) @Nullable Integer refreshProgressBarBackgroundColor, @Prop(optional = true, resType = ResType.COLOR) int refreshProgressBarColor, @Prop(optional = true) boolean clipChildren, @Prop(optional = true) boolean nestedScrollingEnabled, @Prop(optional = true) int scrollBarStyle, @Prop(optional = true) RecyclerView.ItemDecoration itemDecoration, @Prop(optional = true) boolean horizontalFadingEdgeEnabled, @Prop(optional = true) boolean verticalFadingEdgeEnabled, @Prop(optional = true, resType = ResType.DIMEN_SIZE) int fadingEdgeLength, @Prop(optional = true) @IdRes int recyclerViewId, @Prop(optional = true) int overScrollMode, @Prop(optional = true, isCommonProp = true) CharSequence contentDescription, @Prop(optional = true) ItemAnimator itemAnimator) { final RecyclerView recyclerView = sectionsRecycler.getRecyclerView(); if (recyclerView == null) { throw new IllegalStateException( "RecyclerView not found, it should not be removed from SwipeRefreshLayout"); } recyclerView.setContentDescription(contentDescription); recyclerView.setHasFixedSize(hasFixedSize); recyclerView.setClipToPadding(clipToPadding); sectionsRecycler.setClipToPadding(clipToPadding); ViewCompat.setPaddingRelative( recyclerView, leftPadding, topPadding, rightPadding, bottomPadding); recyclerView.setClipChildren(clipChildren); sectionsRecycler.setClipChildren(clipChildren); recyclerView.setNestedScrollingEnabled(nestedScrollingEnabled); sectionsRecycler.setNestedScrollingEnabled(nestedScrollingEnabled); recyclerView.setScrollBarStyle(scrollBarStyle); recyclerView.setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled); recyclerView.setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled); recyclerView.setFadingEdgeLength(fadingEdgeLength); // TODO (t14949498) determine if this is necessary recyclerView.setId(recyclerViewId); recyclerView.setOverScrollMode(overScrollMode); if (refreshProgressBarBackgroundColor != null) { sectionsRecycler.setProgressBackgroundColorSchemeColor(refreshProgressBarBackgroundColor); } sectionsRecycler.setColorSchemeColors(refreshProgressBarColor); if (itemDecoration != null) { recyclerView.addItemDecoration(itemDecoration); } sectionsRecycler.setItemAnimator( itemAnimator != RecyclerSpec.itemAnimator ? itemAnimator : new NoUpdateItemAnimator()); binder.mount(recyclerView); }
Example 14
Source File: FollowingItemDecoration.java From Mysplash with GNU Lesser General Public License v3.0 | 4 votes |
private void setParentPadding(RecyclerView parent, Rect insets) { parent.setPadding(insets.left, 0, insets.right, insets.bottom); parent.setClipToPadding(false); }