Commit 5dbcfcb3 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Disable BottomNavigationView shift mode, show menu item titles and downgrade compile SDK version

parent 88892c33
......@@ -5,11 +5,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
compileSdkVersion 27
defaultConfig {
applicationId "io.eelo.appinstaller"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
......@@ -25,9 +25,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
......
......@@ -2,11 +2,40 @@ package io.eelo.appinstaller
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.design.internal.BottomNavigationItemView
import android.support.design.internal.BottomNavigationMenuView
import android.support.design.widget.BottomNavigationView
import android.annotation.SuppressLint
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
removeShiftMode(bottom_navigation_view)
}
@SuppressLint("RestrictedApi")
private fun removeShiftMode(bottomNavigationView: BottomNavigationView) {
val menuView = bottomNavigationView.getChildAt(0) as BottomNavigationMenuView
try {
val mShiftingMode = menuView.javaClass.getDeclaredField("mShiftingMode")
mShiftingMode.isAccessible = true
mShiftingMode.setBoolean(menuView, false)
mShiftingMode.isAccessible = false
} catch (e: NoSuchFieldException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
for (i in 0 until menuView.childCount) {
val itemView = menuView.getChildAt(i) as BottomNavigationItemView
itemView.setShiftingMode(false)
itemView.setChecked(itemView.itemData.isChecked)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment