My problem:
I 'm having an issue and cannot determine why the ViewPager will not display the tab fragment fields unless I hard code the 'layout_height" parameter? Below I have an image of what happens and what my goal is.
The ViewPager resides in the ConstraintLayout beneath the TabLayout. The 'blueprint" layout provides a visual image of the ViewPager constrained to the ConstraintLayout to expand as needed.
What I have tried:
I have watched 3-4 TabLayout tutorials and read various documentation. The only difference between my project and those is that my activity is not specifically restricted to just the tab layout, but begins after the other fields. However, I'm not sure this has an impact because, as I said, if I hard code the height of the ViewPager each tab fragment content can be seen within each tab.
Let me know what else may be needed to help assist my issue since I provided limited code (see below).
What happens:
The Goal:
The white line is both the ViewPager constrained to the Constraint Layout
Related code (ViewPager setup and ViewPager XML):
I 'm having an issue and cannot determine why the ViewPager will not display the tab fragment fields unless I hard code the 'layout_height" parameter? Below I have an image of what happens and what my goal is.
The ViewPager resides in the ConstraintLayout beneath the TabLayout. The 'blueprint" layout provides a visual image of the ViewPager constrained to the ConstraintLayout to expand as needed.
What I have tried:
I have watched 3-4 TabLayout tutorials and read various documentation. The only difference between my project and those is that my activity is not specifically restricted to just the tab layout, but begins after the other fields. However, I'm not sure this has an impact because, as I said, if I hard code the height of the ViewPager each tab fragment content can be seen within each tab.
Let me know what else may be needed to help assist my issue since I provided limited code (see below).
What happens:
The Goal:
The white line is both the ViewPager constrained to the Constraint Layout
Related code (ViewPager setup and ViewPager XML):
Java:
SectionsPageAdapter adapter = new SectionsPageAdapter(getSupportFragmentManager());
adapter.addFragment(new SourceFragment(noteDetails.get(2), noteDetails.get(3)), "Source");
adapter.addFragment(new QuoteTermFragment(noteDetails.get(5), noteDetails.get(6)), "Quote and Term");
adapter.addFragment(new FilesFragment(), "File");
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
XML:
//.... tablayout code and items....
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_ViewPager"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/view_Tab_Layout"
android:layout_margin="5dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
</androidx.viewpager.widget.ViewPager>
</androidx.constraintlayout.widget.ConstraintLayout>