Java Code Examples for android.support.v7.widget.RecyclerView#setClipToPadding()

The following examples show how to use android.support.v7.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: RecyclerViewFragment.java    From KA27 with Apache License 2.0 6 votes vote down vote up
public void setOnScrollListener(RecyclerView recyclerView) {
    if (recyclerView != null) {
        int paddingBottom = recyclerView.getPaddingBottom() +
            getResources().getDimensionPixelSize(R.dimen.basecard_padding);
        if (applyOnBootLayout != null) {
            recyclerView.setPadding(0, applyOnBootLayout.getHeight(), 0, firstOpening ? paddingBottom :
                recyclerView.getPaddingBottom());
            resetTranslations();

            if (!Utils.isTV(getActivity()))
                recyclerView.addOnScrollListener(onScrollListener = new CustomScrollListener());
        } else recyclerView.setPadding(0, 0, 0, firstOpening ? paddingBottom :
            recyclerView.getPaddingBottom());
        recyclerView.setClipToPadding(false);
    }
}
 
Example 2
Source File: RecyclerViewFragment.java    From kernel_adiutor with Apache License 2.0 6 votes vote down vote up
public void setOnScrollListener(RecyclerView recyclerView) {
    if (recyclerView != null) {
        int paddingBottom = recyclerView.getPaddingBottom()
                + getResources().getDimensionPixelSize(R.dimen.basecard_padding);
        if (applyOnBootLayout != null) {
            recyclerView.setPadding(0, applyOnBootLayout.getHeight(), 0, firstOpening ? paddingBottom
                    : recyclerView.getPaddingBottom());
            resetTranslations();

            if (!Utils.isTV(getActivity()))
                recyclerView.addOnScrollListener(onScrollListener = new CustomScrollListener());
        } else recyclerView.setPadding(0, 0, 0, firstOpening ? paddingBottom
                : recyclerView.getPaddingBottom());
        recyclerView.setClipToPadding(false);
    }
}
 
Example 3
Source File: ColorActivity.java    From GreatFit with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RecyclerView root = new RecyclerView(this);
    //Add header to a list of settings
    List<BaseSetting> settings = new ArrayList<>();
    settings.add(new HeaderSetting(getString(R.string.set_color)));
    //Setup items for each day
    String[] colors = getResources().getStringArray(R.array.colors);
    String[] colorCodes = getResources().getStringArray(R.array.color_codes);
    final SharedPreferences sharedPreferences = getSharedPreferences(getPackageName()+"_settings", Context.MODE_PRIVATE);
    int x = 0;
    int current = sharedPreferences.getInt("color", -1);
    for(String color : colors){
        //Each item needs a Setting
        final int finalX = x;
        settings.add(new IconSetting( (current==x)?getDrawable(R.drawable.check):getDrawable(R.drawable.circle_icon), color, null, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sharedPreferences.edit().putInt("color", finalX).apply();
                ColorActivity.this.finish();
            }
        }, Color.parseColor(colorCodes[x])));
        x++;
    }
    //Setup layout
    root.setBackgroundResource(R.drawable.settings_background);
    root.setLayoutManager(new LinearLayoutManager(this));
    root.setAdapter(new Adapter(this, settings));
    root.setPadding((int) getResources().getDimension(R.dimen.padding_round_small), 0, (int) getResources().getDimension(R.dimen.padding_round_small), (int) getResources().getDimension(R.dimen.padding_round_large));
    root.setClipToPadding(false);
    setContentView(root);
}
 
Example 4
Source File: FontActivity.java    From GreatFit with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RecyclerView root = new RecyclerView(this);
    //Add header to a list of settings
    List<BaseSetting> settings = new ArrayList<>();
    settings.add(new HeaderSetting(getString(R.string.set_font)));
    //Setup items for each day
    String[] fonts = ResourceManager.getNames(ResourceManager.Font.class);//getResources().getStringArray(R.array.colors);
    final SharedPreferences sharedPreferences = getSharedPreferences(getPackageName()+"_settings", Context.MODE_PRIVATE);
    int x = 0;
    int current = sharedPreferences.getInt("font", 0);
    for(String font : fonts){
        //Each item needs a Setting
        final int finalX = x;
        settings.add(new IconSetting( (current==x)?getDrawable(R.drawable.check):getDrawable(R.drawable.circle_icon), font, null, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sharedPreferences.edit().putInt("font", finalX).apply();
                FontActivity.this.finish();
            }
        }, x));
        x++;
    }
    //Setup layout
    root.setBackgroundResource(R.drawable.settings_background);
    root.setLayoutManager(new LinearLayoutManager(this));
    root.setAdapter(new Adapter(this, settings));
    root.setPadding((int) getResources().getDimension(R.dimen.padding_round_small), 0, (int) getResources().getDimension(R.dimen.padding_round_small), (int) getResources().getDimension(R.dimen.padding_round_large));
    root.setClipToPadding(false);
    setContentView(root);
}
 
Example 5
Source File: GridSpacingItemDecoration.java    From SimpleVideoEdit with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: BaseLayoutMargin.java    From recycler-view-margin-decoration with Apache License 2.0 5 votes vote down vote up
void setPadding( RecyclerView rv,
                 @Px int top,
                 @Px int bottom,
                 @Px int left,
                 @Px int right ){
    rv.setClipToPadding( false );
    rv.setScrollBarStyle( SCROLLBARS_OUTSIDE_OVERLAY );
    rv.setPadding( left, top, right, bottom );
}
 
Example 7
Source File: LabelSelectionFragment.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mRecyclerView = new RecyclerView(inflater.getContext());
/*    mRecyclerView.setPadding(
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()),
            0
    );*/
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setClipChildren(false);
    return mRecyclerView;
}
 
Example 8
Source File: ContentLoaderView.java    From Sky31Radio with Apache License 2.0 5 votes vote down vote up
private void initViews(){
    inflate(getContext(), R.layout.merge_content_loader, this);
    setPadding(0, 0, 0, 0);
    setClickable(true);
    errorView = findViewById(R.id.error_view);
    emptyView = findViewById(R.id.empty_view);
    loadingView = findViewById(R.id.loading_view);
    refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresher);
    recyclerView = (RecyclerView) findViewById(R.id.recycler);
    errorRetryBtn = (Button) findViewById(R.id.btn_error_retry);
    errorMessageTV = (TextView) findViewById(R.id.error_message);
    emptyRetryBtn = (Button) findViewById(R.id.btn_empty_retry);
    emptyMessageTV = (TextView) findViewById(R.id.empty_message);

    errorRetryBtn.setOnClickListener(this);
    emptyRetryBtn.setOnClickListener(this);
    contentView = refreshLayout;
    refreshLayout.setEnabled(false);
    refreshLayout.setColorSchemeResources(
            android.R.color.holo_blue_light,
            android.R.color.holo_purple,
            android.R.color.holo_green_light,
            android.R.color.holo_red_light,
            android.R.color.holo_orange_light);
    refreshLayout.setOnRefreshListener(this);
    recyclerView.setOnScrollListener(mRecyclerScrollListener);
    if(padding!=-1){
        recyclerView.setPadding(padding, padding, padding,padding);
    }else{
        recyclerView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    }
    recyclerView.setClipToPadding(clipToPadding);
    setDisplayState(STATE_LOADING);
}
 
Example 9
Source File: VerticalStepperView.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
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 10
Source File: GridDecoration.java    From memetastic with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: SearchBar.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
protected void initRecyclerView() {
    _searchRecycler = new RecyclerView(getContext());
    _searchRecycler.setItemAnimator(null);
    _searchRecycler.setVisibility(View.GONE);
    _searchRecycler.setAdapter(_adapter);
    _searchRecycler.setClipToPadding(false);
    _searchRecycler.setHasFixedSize(true);
    updateRecyclerViewLayoutManager();
}
 
Example 12
Source File: DesktopOptionView.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
private RecyclerView createRecyclerView(FastAdapter adapter, int gravity, int paddingHorizontal) {
    RecyclerView actionRecyclerView = new RecyclerView(getContext());
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
    actionRecyclerView.setClipToPadding(false);
    actionRecyclerView.setPadding(paddingHorizontal, 0, paddingHorizontal, 0);
    actionRecyclerView.setLayoutManager(linearLayoutManager);
    actionRecyclerView.setAdapter(adapter);
    actionRecyclerView.setOverScrollMode(OVER_SCROLL_ALWAYS);
    LayoutParams actionRecyclerViewLP = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    actionRecyclerViewLP.gravity = gravity;

    addView(actionRecyclerView, actionRecyclerViewLP);
    return actionRecyclerView;
}
 
Example 13
Source File: SpacingItemDecoration.java    From glide-support with The Unlicense 5 votes vote down vote up
@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 14
Source File: MiniDrawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
/**
 * build the MiniDrawer
 *
 * @param ctx
 * @return
 */
public View build(Context ctx) {
    mContainer = new LinearLayout(ctx);
    if (mInnerShadow) {
        if (!mInRTL) {
            mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_left);
        } else {
            mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_right);
        }
    }

    //create and append recyclerView
    mRecyclerView = new RecyclerView(ctx);
    mContainer.addView(mRecyclerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    //set the itemAnimator
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    //some style improvements on older devices
    mRecyclerView.setFadingEdgeLength(0);
    //set the drawing cache background to the same color as the slider to improve performance
    //mRecyclerView.setDrawingCacheBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mActivity, R.attr.material_drawer_background, R.color.material_drawer_background));
    mRecyclerView.setClipToPadding(false);
    //additional stuff
    mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
    //adapter
    mDrawerAdapter = new DrawerAdapter();
    mRecyclerView.setAdapter(mDrawerAdapter);

    //if the activity with the drawer should be fullscreen add the padding for the statusbar
    if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentStatusBar)) {
        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), UIUtils.getStatusBarHeight(ctx), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
    }

    //if the activity with the drawer should be fullscreen add the padding for the navigationBar
    if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentNavigationBar)) {
        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), UIUtils.getNavigationBarHeight(ctx));
    }

    //set the adapter with the items
    createItems();

    return mContainer;
}
 
Example 15
Source File: WidgetsActivity.java    From GreatFit with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RecyclerView root = new RecyclerView(this);
    //Add header to a list of settings
    List<BaseSetting> settings = new ArrayList<>();
    settings.add(new HeaderSetting(getString(R.string.set_elements)));
    //Setup items for each day
    String[] elements = getResources().getStringArray(R.array.supported_widgets);
    final SharedPreferences sharedPreferences = getSharedPreferences(getPackageName()+"_settings", Context.MODE_PRIVATE);

    // Get Widgets
    String widgetsAsText = sharedPreferences.getString("widgets", null);
    String text = widgetsAsText.replaceAll("(\\[|\\]| )",""); // Replace "[", "]" and "spaces"
    List <String> widgets_list = Arrays.asList(text.split(","));

    int current = sharedPreferences.getInt("temp_widget", 0);
    String currentAsText = widgets_list.get(current);
    for(String element : elements){
        // Go to next if already a widget
        if(widgets_list.indexOf(element)>=0 && !element.equals(currentAsText) && !element.equals("none")){
            continue;
        }
        // Create the setting
        widgets_list.set(current,element);
        final String finalWidgets = widgets_list.toString();
        settings.add(new IconSetting( (element.equals(currentAsText))?getDrawable(R.drawable.check):getDrawable(R.drawable.circle_icon), prepareTitle(element), prepareSubtitle(element), new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sharedPreferences.edit().putString("widgets", finalWidgets).apply();
                WidgetsActivity.this.finish();
            }
        }, null));
    }
    //Setup layout
    root.setBackgroundResource(R.drawable.settings_background);
    root.setLayoutManager(new LinearLayoutManager(this));
    root.setAdapter(new Adapter(this, settings));
    root.setPadding((int) getResources().getDimension(R.dimen.padding_round_small), 0, (int) getResources().getDimension(R.dimen.padding_round_small), (int) getResources().getDimension(R.dimen.padding_round_large));
    root.setClipToPadding(false);
    setContentView(root);
}
 
Example 16
Source File: EasyRecyclerView.java    From BookReader with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example 17
Source File: EasyRecyclerView.java    From fangzhuishushenqi with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example 18
Source File: ProgressWidgetsActivity.java    From GreatFit with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RecyclerView root = new RecyclerView(this);
    //Add header to a list of settings
    List<BaseSetting> settings = new ArrayList<>();
    settings.add(new HeaderSetting(getString(R.string.set_progress_bar)));

    //Setup items for each day
    String[] elements = getResources().getStringArray(R.array.supported_progress_elements);
    final SharedPreferences sharedPreferences = getSharedPreferences(getPackageName()+"_settings", Context.MODE_PRIVATE);

    // Get Widgets
    String widgetsAsText = sharedPreferences.getString("progress_bars", null);
    String text = widgetsAsText.replaceAll("(\\[|\\]| )",""); // Replace "[", "]" and "spaces"
    List <String> widgets_list = Arrays.asList(text.split(","));

    int current = sharedPreferences.getInt("temp_progress_bars", 0);
    String currentAsText = widgets_list.get(current);
    for(String element : elements){
        // Go to next if already a widget
        if(widgets_list.indexOf(element)>=0 && !element.equals(currentAsText) && !element.equals("none")){
            continue;
        }
        // Create the setting
        widgets_list.set(current,element);
        final String finalWidgets = widgets_list.toString();
        settings.add(new IconSetting( (element.equals(currentAsText))?getDrawable(R.drawable.check):getDrawable(R.drawable.circle_icon), prepareTitle(element), prepareSubtitle(element), new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sharedPreferences.edit().putString("progress_bars", finalWidgets).apply();
                ProgressWidgetsActivity.this.finish();
            }
        }, null));
    }
    //Setup layout
    root.setBackgroundResource(R.drawable.settings_background);
    root.setLayoutManager(new LinearLayoutManager(this));
    root.setAdapter(new Adapter(this, settings));
    root.setPadding((int) getResources().getDimension(R.dimen.padding_round_small), 0, (int) getResources().getDimension(R.dimen.padding_round_small), (int) getResources().getDimension(R.dimen.padding_round_large));
    root.setClipToPadding(false);
    setContentView(root);
}