color the navigation bar too

This commit is contained in:
tibbi
2022-06-24 21:33:24 +02:00
parent 630e9fc1b0
commit d76a6ea6a7
3 changed files with 15 additions and 12 deletions

View File

@ -62,7 +62,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:dea77e0130' implementation 'com.github.SimpleMobileTools:Simple-Commons:f7c3e0ed7c'
implementation 'org.greenrobot:eventbus:3.3.1' implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.github.Armen101:AudioRecordView:1.0.4' implementation 'com.github.Armen101:AudioRecordView:1.0.4'
implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.documentfile:documentfile:1.0.1'

View File

@ -102,16 +102,15 @@ class MainActivity : SimpleActivity() {
private fun setupViewPager() { private fun setupViewPager() {
main_tabs_holder.removeAllTabs() main_tabs_holder.removeAllTabs()
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { val tabDrawables = arrayOf(R.drawable.ic_microphone_vector, R.drawable.ic_headset_vector)
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(R.drawable.ic_microphone_vector)) val tabLabels = arrayOf(R.string.recorder, R.string.player)
customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(R.string.recorder)
main_tabs_holder.addTab(this)
}
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { tabDrawables.forEachIndexed { i, drawableId ->
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(R.drawable.ic_headset_vector)) main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(R.string.player) customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(drawableId))
main_tabs_holder.addTab(this) customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(tabLabels[i])
main_tabs_holder.addTab(this)
}
} }
main_tabs_holder.onTabSelectionChanged( main_tabs_holder.onTabSelectionChanged(
@ -141,6 +140,11 @@ class MainActivity : SimpleActivity() {
val inactiveView = main_tabs_holder.getTabAt(getInactiveTabIndex())?.customView val inactiveView = main_tabs_holder.getTabAt(getInactiveTabIndex())?.customView
updateBottomTabItemColors(activeView, true) updateBottomTabItemColors(activeView, true)
updateBottomTabItemColors(inactiveView, false) updateBottomTabItemColors(inactiveView, false)
main_tabs_holder.getTabAt(view_pager.currentItem)?.select()
val bottomBarColor = getBottomTabsBackgroundColor()
main_tabs_holder.setBackgroundColor(bottomBarColor)
updateNavigationBarColor(bottomBarColor)
} }
private fun getInactiveTabIndex() = if (view_pager.currentItem == 0) 1 else 0 private fun getInactiveTabIndex() = if (view_pager.currentItem == 0) 1 else 0

View File

@ -18,7 +18,6 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
app:tabIndicator="@null" app:tabIndicator="@null"
app:tabMinWidth="150dp" app:tabMinWidth="150dp"
app:tabRippleColor="@null"> app:tabRippleColor="@null" />
</com.google.android.material.tabs.TabLayout>
</RelativeLayout> </RelativeLayout>