You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried your header decorator in my application, it has a tab layout and inside the tab layout there's a fragment. I'm using the header layout in the recycler view in that fragment. The problem is that when the fragment is first created the item isn't decorated, but after scrolling down and back up again the header is shown. Maybe you can shed some light why that happening.
Here's the attached gif
Here's the code, the initRecyclerView is called from Fragment.onCreateView(). Thanks for the help
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
// use a linear layout manager
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity().getApplicationContext(), new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Trayek trayek = adapter.getItem(position);
if(trayek != null) {
Intent intent = new Intent(getActivity().getApplicationContext(), AngkotRouteActivity.class);
intent.putExtra("bus_code", trayek.getVehicleNo());
intent.putExtra("bus_name", trayek.getVehicleName());
intent.putExtra("id_trayek", trayek.getId());
startActivity(intent);
}
}
}));
recyclerView.addItemDecoration(HeaderDecoration.with(recyclerView)
.inflate(R.layout.header_damri)
.parallax(1f)
.dropShadowDp(4)
.build());
}
``
The text was updated successfully, but these errors were encountered:
I'm sorry I couldn't find the time to look into this issue yet
I'm guessing this could be due to the ViewPager, preparing the fragment in the background, before it gets displayed. It could be that the height of the recyclerview is measured as 0 and thus drawing the decoration wrong (If you have a look at this methog here)
I believe you would do best to just attach a debugger and step it through :)
Hi, no problem. I already implement it using another way, but i really-really like the item decoration approach. I'll see if i can understand the part that you linked.
Hi, first thanks for the great samples.
I tried your header decorator in my application, it has a tab layout and inside the tab layout there's a fragment. I'm using the header layout in the recycler view in that fragment. The problem is that when the fragment is first created the item isn't decorated, but after scrolling down and back up again the header is shown. Maybe you can shed some light why that happening.
Here's the attached gif
Here's the code, the initRecyclerView is called from Fragment.onCreateView(). Thanks for the help
``
private void initRecyclerView(View v) {
recyclerView = (RecyclerView) v.findViewById(R.id.recyclerview);
``
The text was updated successfully, but these errors were encountered: