Have a horizontal recyclerview. Want the width to be less than match_parent only able to view some pixels of the next item. Is there a way to do this?
First of all get the screen width.
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager windowmanager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
windowmanager.getDefaultDisplay().getMetrics(displayMetrics);
int deviceWidth = displayMetrics.widthPixels;
Then in your adapter fix the width of your view:-
item_width = deviceWidth - (deviceWidth/100 * 10);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With