底部操作栏阴影跟随设置调节

pull/401/head^2
gedoor 4 years ago
parent 49accb3593
commit e394d4e89c
  1. 3
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  2. 5
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt
  3. 15
      app/src/main/res/layout/activity_main.xml

@ -19,6 +19,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Backup
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.elevation
import io.legado.app.service.BaseReadAloudService import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.main.bookshelf.BookshelfFragment import io.legado.app.ui.main.bookshelf.BookshelfFragment
import io.legado.app.ui.main.explore.ExploreFragment import io.legado.app.ui.main.explore.ExploreFragment
@ -47,6 +48,8 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
view_pager_main.offscreenPageLimit = 3 view_pager_main.offscreenPageLimit = 3
view_pager_main.adapter = TabFragmentPageAdapter(supportFragmentManager) view_pager_main.adapter = TabFragmentPageAdapter(supportFragmentManager)
view_pager_main.addOnPageChangeListener(this) view_pager_main.addOnPageChangeListener(this)
bottom_navigation_view.elevation =
if (AppConfig.elevation < 0) elevation else AppConfig.elevation.toFloat()
bottom_navigation_view.setOnNavigationItemSelectedListener(this) bottom_navigation_view.setOnNavigationItemSelectedListener(this)
bottom_navigation_view.setOnNavigationItemReselectedListener(this) bottom_navigation_view.setOnNavigationItemReselectedListener(this)
bottom_navigation_view.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS bottom_navigation_view.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS

@ -9,9 +9,9 @@ import androidx.annotation.MenuRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import io.legado.app.R import io.legado.app.R
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.* import io.legado.app.lib.theme.*
import io.legado.app.utils.ColorUtils import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.visible import io.legado.app.utils.visible
import kotlinx.android.synthetic.main.view_select_action_bar.view.* import kotlinx.android.synthetic.main.view_select_action_bar.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
@ -22,7 +22,8 @@ class SelectActionBar(context: Context, attrs: AttributeSet?) : FrameLayout(cont
init { init {
setBackgroundColor(context.bottomBackground) setBackgroundColor(context.bottomBackground)
elevation = 10.dp.toFloat() elevation =
if (AppConfig.elevation < 0) context.elevation else AppConfig.elevation.toFloat()
View.inflate(context, R.layout.view_select_action_bar, this) View.inflate(context, R.layout.view_select_action_bar, this)
val textIsDark = ColorUtils.isColorLight(context.bottomBackground) val textIsDark = ColorUtils.isColorLight(context.bottomBackground)
val primaryTextColor = context.getPrimaryTextColor(textIsDark) val primaryTextColor = context.getPrimaryTextColor(textIsDark)

@ -4,21 +4,20 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager_main"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation_view" android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
android:elevation="10dp"
android:background="@color/background" android:background="@color/background"
app:labelVisibilityMode="unlabeled" app:labelVisibilityMode="unlabeled"
app:menu="@menu/main_bnv" app:menu="@menu/main_bnv"
app:layout_constraintBottom_toBottomOf="parent" /> app:layout_constraintBottom_toBottomOf="parent" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager_main"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save