Advertisement
PedroBarbosa

Untitled

May 1st, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1. package com.quarkprojects.smashi.utils;
  2.  
  3.  
  4. import android.content.Context;
  5. import android.graphics.Rect;
  6. import android.support.v7.widget.RecyclerView;
  7. import android.view.View;
  8.  
  9. import com.quarkprojects.smashi.R;
  10.  
  11.  
  12. /**
  13.  * Created by black on 01/05/2016.
  14.  */
  15. /*
  16.  * Copyright (C) 2015 Saúl Molinero.
  17.  *
  18.  * Licensed under the Apache License, Version 2.0 (the "License");
  19.  * you may not use this file except in compliance with the License.
  20.  * You may obtain a copy of the License at
  21.  *
  22.  * http://www.apache.org/licenses/LICENSE-2.0
  23.  *
  24.  * Unless required by applicable law or agreed to in writing, software
  25.  * distributed under the License is distributed on an "AS IS" BASIS,
  26.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  27.  * See the License for the specific language governing permissions and
  28.  * limitations under the License.
  29.  */
  30.  
  31.  
  32.  
  33. /**
  34.  * ItemDecoration implementation that applies an inset margin
  35.  * around each child of the RecyclerView. The inset value is controlled
  36.  * by a dimension resource.
  37.  *
  38.  * by Dave Smith at: https://github.com/devunwired/recyclerview-playground
  39.  */
  40.  
  41. public class RecyclerInsetsDecoration extends RecyclerView.ItemDecoration {
  42.  
  43.     private int mInsets;
  44.  
  45.     public RecyclerInsetsDecoration(Context context) {
  46.         mInsets = context.getResources().getDimensionPixelSize(R.dimen.insets);
  47.     }
  48.  
  49.     @Override
  50.     public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
  51.  
  52.         //We can supply forced insets for each item view here in the Rect
  53.         super.getItemOffsets(outRect, view, parent, state);
  54.         outRect.set(mInsets, mInsets, mInsets, mInsets);
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement