I am implementing a RecyclerView, I require the width of the fragment as it directly affects the items in the RecyclerView. Where and how is the best option to do this? I am also looking for a solution that satisfies orientation changes (portrait/landscape) and that is able to redraw according to these changes.
There are two types of ways getting the width that I know of:
- getView().getViewTreeObserver().addOnGlobalLayoutListener...
- MyOnResizeListener orlResized = new MyOnResizeListener() {...};
I create my adapter in onViewCreated() and the two above methods are firing after my adapter item views are created, which is of no use then.
Is there any good practice way to solving this?