Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
App Lounge
Commits
5dbcfcb3
Commit
5dbcfcb3
authored
Aug 10, 2018
by
Nihar Thakkar
Browse files
Disable BottomNavigationView shift mode, show menu item titles and downgrade compile SDK version
parent
88892c33
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/build.gradle
View file @
5dbcfcb3
...
...
@@ -5,11 +5,11 @@ apply plugin: 'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
android
{
compileSdkVersion
2
8
compileSdkVersion
2
7
defaultConfig
{
applicationId
"io.eelo.appinstaller"
minSdkVersion
21
targetSdkVersion
2
8
targetSdkVersion
2
7
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:2
8.0.0-rc0
1'
implementation
'com.android.support:appcompat-v7:2
7.1.
1'
implementation
'com.android.support.constraint:constraint-layout:1.1.2'
implementation
'com.android.support:design:2
8.0.0-rc0
1'
implementation
'com.android.support:design:2
7.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'
...
...
app/src/main/java/io/eelo/appinstaller/MainActivity.kt
View file @
5dbcfcb3
...
...
@@ -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
)
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment