Using the Master/Detail template in ViewPager Fragments (download link)
Asked Answered
O

1

2

Working code: https://github.com/lukeallison/ViewPagerMasterDetail

Android Master/Detail Flow template: http://developer.android.com/tools/projects/templates.html#master-detail-activity

Description: Using the Master/Detail Flow template available in Android Studio, my application utilizes a ViewPager to manage three Parent fragments. The third fragment is a Master (list), which has a Child (detail) fragment.

Issues:

  1. When fragment_item_list is first inflated the App Bar pushes the last item of the list below the bounds of the screen. This issue is no longer present after rotating the device. Simply adding padding to the bottom of the screen will not fix the issue as it will leave an unwanted space at the bottom of the screen after rotating. Numerous SO threads have failed to address this issue. - Fixed
  2. Requires android:configChanges="orientation|keyboardHidden|screenSize" in order for the Child (detail) fragment to inflate the correct layout when rotated. I'd like to not have to enforce this. PLEASE help fix this bug.
  3. Uses deprecated setOnPageChangeListener and onAttach(Activity)
  4. Upgrading the dependencies to 23.2.0 results in the ItemListFragment failing to inflate the correct Fragment when rotated so I can't update the libraries in the application
  5. The code is probably more cumbersome than necessary

Please help me fix these bugs so we have a template that myself and others can use.

Orvalorvan answered 9/3, 2016 at 13:38 Comment(2)
I'm not able to reproduce the bug in my 4.4.2 Android. I see all 25 items in the Master list without the need to rotate. What version are you using? Add some screenshots to better explain the bound issues. 'ItemListFragment': there is not fragment with that name in your repo. Do you mean 'ItemDetailFragment'? Perhaps you forgot to push the last changes?Stingo
Please try the updated repository. I pushed the wrong project initially.Orvalorvan
O
0

Bug fix. The List in fragment_item_list.xml now displays the last element of the List on initial and subsequent layout inflation. I added <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> to style.xml and ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); to the initLayout method of ItemListFragment.java.

Orvalorvan answered 10/3, 2016 at 9:13 Comment(1)
This is far from a good solution. A hack at best. What if I want a toolbar? What if I have a custom layout at the top whose height I cannot know before runtime.Antecedence

© 2022 - 2024 — McMap. All rights reserved.