How to set horizontal scroll with show next and previous data in RecyclerView
up vote
0
down vote
favorite
In my application i want use recyclerView
for show special data, and for this i want use recyclerview
with horizontal scroll with show next and previous data.
such as banner and below image : enter link description here
How can i use LayoutManager
for this?
For this, i know i should use Horizontal in LinearLayout
. but i don't know how can i show next and previous data
Please don't give me negative points and please help me.
android android-layout android-recyclerview
add a comment |
up vote
0
down vote
favorite
In my application i want use recyclerView
for show special data, and for this i want use recyclerview
with horizontal scroll with show next and previous data.
such as banner and below image : enter link description here
How can i use LayoutManager
for this?
For this, i know i should use Horizontal in LinearLayout
. but i don't know how can i show next and previous data
Please don't give me negative points and please help me.
android android-layout android-recyclerview
Why you can not tryViewPager
– Sniffer
Nov 11 at 5:59
@Sniffer, i want use RecyclerView. can you help me for this?
– DJ Al
Nov 11 at 6:01
next/previous arrow indicator please follow this link it work for me.
– dhananjay singh
Nov 11 at 6:13
@dhananjaysingh, thanks dear but i don't want show next and previous arrow . i want partial next and previous data
– DJ Al
Nov 11 at 6:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In my application i want use recyclerView
for show special data, and for this i want use recyclerview
with horizontal scroll with show next and previous data.
such as banner and below image : enter link description here
How can i use LayoutManager
for this?
For this, i know i should use Horizontal in LinearLayout
. but i don't know how can i show next and previous data
Please don't give me negative points and please help me.
android android-layout android-recyclerview
In my application i want use recyclerView
for show special data, and for this i want use recyclerview
with horizontal scroll with show next and previous data.
such as banner and below image : enter link description here
How can i use LayoutManager
for this?
For this, i know i should use Horizontal in LinearLayout
. but i don't know how can i show next and previous data
Please don't give me negative points and please help me.
android android-layout android-recyclerview
android android-layout android-recyclerview
edited Nov 16 at 1:14
Andrew Thompson
152k27162336
152k27162336
asked Nov 11 at 5:42
DJ Al
116
116
Why you can not tryViewPager
– Sniffer
Nov 11 at 5:59
@Sniffer, i want use RecyclerView. can you help me for this?
– DJ Al
Nov 11 at 6:01
next/previous arrow indicator please follow this link it work for me.
– dhananjay singh
Nov 11 at 6:13
@dhananjaysingh, thanks dear but i don't want show next and previous arrow . i want partial next and previous data
– DJ Al
Nov 11 at 6:20
add a comment |
Why you can not tryViewPager
– Sniffer
Nov 11 at 5:59
@Sniffer, i want use RecyclerView. can you help me for this?
– DJ Al
Nov 11 at 6:01
next/previous arrow indicator please follow this link it work for me.
– dhananjay singh
Nov 11 at 6:13
@dhananjaysingh, thanks dear but i don't want show next and previous arrow . i want partial next and previous data
– DJ Al
Nov 11 at 6:20
Why you can not try
ViewPager
– Sniffer
Nov 11 at 5:59
Why you can not try
ViewPager
– Sniffer
Nov 11 at 5:59
@Sniffer, i want use RecyclerView. can you help me for this?
– DJ Al
Nov 11 at 6:01
@Sniffer, i want use RecyclerView. can you help me for this?
– DJ Al
Nov 11 at 6:01
next/previous arrow indicator please follow this link it work for me.
– dhananjay singh
Nov 11 at 6:13
next/previous arrow indicator please follow this link it work for me.
– dhananjay singh
Nov 11 at 6:13
@dhananjaysingh, thanks dear but i don't want show next and previous arrow . i want partial next and previous data
– DJ Al
Nov 11 at 6:20
@dhananjaysingh, thanks dear but i don't want show next and previous arrow . i want partial next and previous data
– DJ Al
Nov 11 at 6:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Assuming you need to only show one full item at a time and 2 partial items at both the sides. You can use snaphelper
to snap recylerview to nearest item position for having the desired effect. And change the width of your item inside the recycler view in the following way. You need to pass the recyclerView
reference inside your adapter to get the width.
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
final SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
and in your onCreateViewHolder
change the width of your item.
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int i)
final View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_view, parent, false);
// recyclerView is your passed view.
int width = recyclerView.getWidth();
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = (int)(width * 0.8);
view.setLayoutParams(params);
return new YourViewHolder(view);
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
|
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Assuming you need to only show one full item at a time and 2 partial items at both the sides. You can use snaphelper
to snap recylerview to nearest item position for having the desired effect. And change the width of your item inside the recycler view in the following way. You need to pass the recyclerView
reference inside your adapter to get the width.
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
final SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
and in your onCreateViewHolder
change the width of your item.
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int i)
final View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_view, parent, false);
// recyclerView is your passed view.
int width = recyclerView.getWidth();
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = (int)(width * 0.8);
view.setLayoutParams(params);
return new YourViewHolder(view);
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
|
show 4 more comments
up vote
0
down vote
accepted
Assuming you need to only show one full item at a time and 2 partial items at both the sides. You can use snaphelper
to snap recylerview to nearest item position for having the desired effect. And change the width of your item inside the recycler view in the following way. You need to pass the recyclerView
reference inside your adapter to get the width.
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
final SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
and in your onCreateViewHolder
change the width of your item.
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int i)
final View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_view, parent, false);
// recyclerView is your passed view.
int width = recyclerView.getWidth();
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = (int)(width * 0.8);
view.setLayoutParams(params);
return new YourViewHolder(view);
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
|
show 4 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Assuming you need to only show one full item at a time and 2 partial items at both the sides. You can use snaphelper
to snap recylerview to nearest item position for having the desired effect. And change the width of your item inside the recycler view in the following way. You need to pass the recyclerView
reference inside your adapter to get the width.
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
final SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
and in your onCreateViewHolder
change the width of your item.
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int i)
final View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_view, parent, false);
// recyclerView is your passed view.
int width = recyclerView.getWidth();
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = (int)(width * 0.8);
view.setLayoutParams(params);
return new YourViewHolder(view);
Assuming you need to only show one full item at a time and 2 partial items at both the sides. You can use snaphelper
to snap recylerview to nearest item position for having the desired effect. And change the width of your item inside the recycler view in the following way. You need to pass the recyclerView
reference inside your adapter to get the width.
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
final SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
and in your onCreateViewHolder
change the width of your item.
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int i)
final View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_view, parent, false);
// recyclerView is your passed view.
int width = recyclerView.getWidth();
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = (int)(width * 0.8);
view.setLayoutParams(params);
return new YourViewHolder(view);
edited Nov 11 at 6:36
answered Nov 11 at 6:02
Rick Sanchez
728615
728615
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
|
show 4 more comments
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
yes dear i know i should use Horizontal in LinearLayout. but i don't know how can i show next and previous data
– DJ Al
Nov 11 at 6:05
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
do you mean, you want to show the partial next and previous data?
– Rick Sanchez
Nov 11 at 6:06
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Yes my friend. such as above image . can you help me?
– DJ Al
Nov 11 at 6:09
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
Are you here dear? can you help me?
– DJ Al
Nov 11 at 6:20
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
thanks dear, u use int width = recyclerView.getWidth(); code. for use recyclerview i should pass my recyclerview from activity to adapter?
– DJ Al
Nov 11 at 6:35
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246163%2fhow-to-set-horizontal-scroll-with-show-next-and-previous-data-in-recyclerview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why you can not try
ViewPager
– Sniffer
Nov 11 at 5:59
@Sniffer, i want use RecyclerView. can you help me for this?
– DJ Al
Nov 11 at 6:01
next/previous arrow indicator please follow this link it work for me.
– dhananjay singh
Nov 11 at 6:13
@dhananjaysingh, thanks dear but i don't want show next and previous arrow . i want partial next and previous data
– DJ Al
Nov 11 at 6:20