[Android] Fix scrolling up beyond normal bound

tda1009 git at videolan.org
Mon Apr 26 05:14:05 UTC 2021


vlc-android | branch: master | tda1009 <turboeighteen at gmail.com> | Sat Apr 24 21:10:30 2021 +0700| [889b384ff0dfdbeed00b24af2bbd9e2934c1202c] | committer: tda1009

Fix scrolling up beyond normal bound

> https://code.videolan.org/videolan/vlc-android/commit/889b384ff0dfdbeed00b24af2bbd9e2934c1202c
---

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt       | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
index f4a824670..da5650d1d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -136,17 +136,20 @@ open class AudioPlayerContainerActivity : BaseActivity() {
         setSupportActionBar(toolbar)
         appBarLayout = findViewById(R.id.appbar)
         tabLayout = findViewById(R.id.sliding_tabs)
+        tabLayout?.visibility = View.VISIBLE
         appBarLayout.setExpanded(true)
         bottomBar = findViewById(R.id.navigation)
         tabLayout?.viewTreeObserver?.addOnGlobalLayoutListener {
             //add a shadow if there are tabs
-            if (AndroidUtil.isLolliPopOrLater) appBarLayout.elevation = if (tabLayout?.isVisible() == true) 4.dp.toFloat() else 0.dp.toFloat()
+            val isTabLayoutShown = (tabLayout?.layoutParams?.height != 0)
+            if (AndroidUtil.isLolliPopOrLater) appBarLayout.elevation = if (isTabLayoutShown) 4.dp.toFloat() else 0.dp.toFloat()
         }
         audioPlayerContainer = findViewById(R.id.audio_player_container)
     }
 
     fun setTabLayoutVisibility(show: Boolean) {
-        tabLayout?.visibility = if (show) View.VISIBLE else View.GONE
+        tabLayout?.layoutParams?.height = if (show) ViewGroup.LayoutParams.WRAP_CONTENT else 0
+        tabLayout?.requestLayout()
     }
 
     private fun initAudioPlayer() {



More information about the Android mailing list