优化导航栏位置

pull/1395/head
gedoor 3 years ago
parent 8cfa0984f6
commit f5d875e8a8
  1. 23
      app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt

@ -5,6 +5,8 @@ import android.content.pm.ActivityInfo
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.*
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.FrameLayout
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.core.view.isVisible import androidx.core.view.isVisible
import io.legado.app.R import io.legado.app.R
@ -144,15 +146,32 @@ abstract class ReadBookBaseActivity :
} }
} }
@SuppressLint("RtlHardcoded")
private fun upNavigationBar() { private fun upNavigationBar() {
binding.navigationBar.run { binding.navigationBar.run {
if (bottomDialog > 0 || binding.readMenu.isVisible) { if (bottomDialog > 0 || binding.readMenu.isVisible) {
layoutParams = layoutParams.apply { val navigationBarHeight =
height = if (ReadBookConfig.hideNavigationBar) { if (ReadBookConfig.hideNavigationBar) {
activity?.navigationBarHeight ?: 0 activity?.navigationBarHeight ?: 0
} else { } else {
0 0
} }
when (navigationBarPos) {
0 -> layoutParams = (layoutParams as FrameLayout.LayoutParams).apply {
height = navigationBarHeight
width = MATCH_PARENT
gravity = Gravity.BOTTOM
}
1 -> layoutParams = (layoutParams as FrameLayout.LayoutParams).apply {
height = MATCH_PARENT
width = navigationBarHeight
gravity = Gravity.LEFT
}
2 -> layoutParams = (layoutParams as FrameLayout.LayoutParams).apply {
height = MATCH_PARENT
width = navigationBarHeight
gravity = Gravity.RIGHT
}
} }
visible() visible()
} else { } else {

Loading…
Cancel
Save