# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1620177561 0 # Node ID 7b210f156eefc28d9597bf2684accb54b8ef04b8 # Parent 3bf2f08fdc4510c7789b92a4fcbac6070766405d Android: Fix the notebook tabs visibility. Thank you orbyt on FreeNode for the help! Set the TabLayout to ALIGN_PARENT_TOP or ALIGN_PARENT_BOTTOM and the ViewPager2 to ABOVE or BELOW depending on the requested tab location. Not setting the relative position of the ViewPager2 caused it to fill the entire layout. diff -r 3bf2f08fdc45 -r 7b210f156eef android/DWindows.kt --- a/android/DWindows.kt Mon May 03 07:15:11 2021 +0000 +++ b/android/DWindows.kt Wed May 05 01:19:21 2021 +0000 @@ -23,6 +23,7 @@ import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.collection.SimpleArrayMap +import androidx.core.view.marginStart import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayout @@ -397,17 +398,26 @@ tabs.id = View.generateViewId() pager.id = View.generateViewId() pager.adapter = DWTabViewPagerAdapter() + TabLayoutMediator(tabs, pager) { tab, position -> + //tab.text = "OBJECT ${(position + 1)}" + }.attach() var params: RelativeLayout.LayoutParams = RelativeLayout.LayoutParams(w, h) if(top != 0) { - params.addRule(RelativeLayout.ABOVE, pager.id) + params.addRule(RelativeLayout.ALIGN_PARENT_TOP) } else { - params.addRule(RelativeLayout.BELOW, pager.id) + params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM) } tabs.tabGravity = TabLayout.GRAVITY_FILL tabs.tabMode = TabLayout.MODE_FIXED notebook.addView(tabs, params) - notebook.addView(pager, RelativeLayout.LayoutParams(w, w)) + params = RelativeLayout.LayoutParams(w, w) + if(top != 0) { + params.addRule(RelativeLayout.BELOW, tabs.id) + } else { + params.addRule(RelativeLayout.ABOVE, tabs.id) + } + notebook.addView(pager, params) tabs.addOnTabSelectedListener(object : OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { val adapter = pager.adapter as DWTabViewPagerAdapter