I have a RecyclerView with GridLayoutManager and a button, when i click the button i want to smoothScrollToPosition. My custom view is simply a RelativeLayout containing a TextView. When i run the program on Lollipop everything's fine, i press the button and the application scrolls smoothly to the given position. When i run the same code on pre lollipop devices or virtual machines, i click the button and the app instead of smoothScrolling starts lagScrolling, it scrolls but with so much lag it's not even funny. The same code but with ImageViews instead of TextViews in the custom View doesn't lag, almost at all. Is this a known bug or can it be solved? My code is just a basic implementation of a RecyclerView with adapter but if somebody needs to see it i'll post it.
Asked
Active
Viewed 1,456 times
1 Answers
-2
Please post your CustomView xml and your adapter code.
You probably set your TextView's width to "wrap_content", and then you probably performing TextView setText() inside adapter, causing it to measure the width of the component again each time onBindViewHolder() is called.
You should try changing TextView width to "match_parent" or some static value in dp.
Please take a look at this question

Community
- 1
- 1

Gleb Samsonov
- 19
- 5
-
Thank you, i'll post my code as soon as i can and i'll also test what you said, but where would i set the text if not in the adapter? – alessandro gaboardi Apr 14 '15 at 05:14
-
Setting text in the adapter is totally fine, howewer triggering onMeasure each time text is set is not fine at all. – Gleb Samsonov Apr 15 '15 at 12:29