UI: Improve toolbar hide and show animation
This commit is contained in:
parent
4177e7fe75
commit
ba4ffe0e70
@ -9,12 +9,14 @@ import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.preference.PreferenceManager
|
||||
import android.support.design.widget.AppBarLayout
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.view.OnApplyWindowInsetsListener
|
||||
import android.support.v4.view.ViewCompat
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.support.v7.widget.Toolbar
|
||||
import android.view.*
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.ImageButton
|
||||
import android.widget.Toast
|
||||
@ -98,23 +100,21 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
||||
|
||||
if (NeoPreference.loadBoolean(R.string.key_ui_fullscreen, false)
|
||||
|| NeoPreference.loadBoolean(R.string.key_ui_hide_toolbar, false)) {
|
||||
// val statusBarHeight = FullScreenHelper.getStatusBarHeight(this)
|
||||
// if (statusBarHeight < 0) {
|
||||
toolbar.visibility = if (visible) View.VISIBLE else View.GONE
|
||||
// return
|
||||
// }
|
||||
// val toolbarHeight = toolbar.height
|
||||
//
|
||||
// val translationY = if (visible) toolbarHeight.toFloat() else -toolbarHeight.toFloat()
|
||||
// val visibility = if (visible) View.VISIBLE else View.GONE
|
||||
//
|
||||
// toolbar.animate()
|
||||
// .translationYBy(translationY)
|
||||
// .setDuration(50L)
|
||||
// .withEndAction {
|
||||
// toolbar.visibility = visibility
|
||||
// }
|
||||
// .start()
|
||||
val toolbarHeight = toolbar.height.toFloat()
|
||||
val translationY = if (visible) 0.toFloat() else -toolbarHeight
|
||||
if (visible) {
|
||||
toolbar.visibility = View.VISIBLE
|
||||
toolbar.animate()
|
||||
.translationY(translationY)
|
||||
.start()
|
||||
} else {
|
||||
toolbar.animate()
|
||||
.translationY(translationY)
|
||||
.withEndAction {
|
||||
toolbar.visibility = View.GONE
|
||||
}
|
||||
.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/terminal_background"
|
||||
@ -13,18 +13,19 @@
|
||||
android:background="@color/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark"
|
||||
android:visibility="visible"
|
||||
custom:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
|
||||
|
||||
|
||||
<de.mrapp.android.tabswitcher.TabSwitcher
|
||||
android:id="@+id/tab_switcher"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
custom:layoutPolicy="auto"
|
||||
custom:tabBackgroundColor="@color/tab_background_color"
|
||||
custom:tabCloseButtonIcon="@drawable/ic_close_tab_18dp"
|
||||
custom:tabIcon="@drawable/ic_tab_icon"
|
||||
custom:tabTitleTextColor="@color/tab_title_text_color"
|
||||
custom:toolbarMenu="@menu/menu_main"
|
||||
custom:toolbarNavigationIcon="@drawable/ic_add_box_white_24dp" />
|
||||
app:layoutPolicy="auto"
|
||||
app:tabBackgroundColor="@color/tab_background_color"
|
||||
app:tabCloseButtonIcon="@drawable/ic_close_tab_18dp"
|
||||
app:tabIcon="@drawable/ic_tab_icon"
|
||||
app:tabTitleTextColor="@color/tab_title_text_color"
|
||||
app:toolbarMenu="@menu/menu_main"
|
||||
app:toolbarNavigationIcon="@drawable/ic_add_box_white_24dp" />
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user