根据材料设计规范,当键盘出现时,BottomNavigationView
应该隐藏在它下面.但是,如果我android:windowSoftInputMode="adjustResize"
在Activity的清单中设置BottomNavigationView
了键盘上方的移动.
我需要设置adjustResize
为在键盘打开时滚动到屏幕底部.但是,我不希望它BottomNavigationView
是可见的.可以这样做吗?
它目前的样子:
布局XML(实际上会有一个FrameLayout
在哪里,EditText
并且EditText
将在其中):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Input"
android:layout_gravity="center"
android:layout_centerVertical="true"/>
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:menu="@menu/menu_bottom_navigation"
app:itemIconTint="@android:color/white"
app:itemTextColor="@android:color/white"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) Android操作系统在内存不足时会终止进程.场景:Android杀死应用程序进程,我通过Android启动器或最近任务列表(长按主页按钮)重新打开它.我可以使用以下方法检查Android是否在最近查看的活动的onCreate()方法中杀死了我的应用程序进程:
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
// Re-initialise things that killing the app would have destroyed
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果Android杀死应用程序进程并使用打包在PendingIntent中的Intent通过Notification重新打开它,我不知道如何确定应用程序进程是否被Android杀死.随后我不会重新初始化杀死应用程序进程会破坏的内容.
有没有办法确定Android是否在从通知中打开新活动时杀死了应用程序进程?
我找到了一个解决这个问题的hacky解决方案.使用:Android:在点击通知时始终启动顶级活动我可以在堆栈顶部打开活动,如果Android杀死应用程序进程并处理重新初始化,则会传递savedInstanceState.然后,每个活动负责使用原始通知意图中的额外内容将用户重定向到相应的活动.此方案的意图设置如下:
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Run Code Online (Sandbox Code Playgroud)
我是否可以在Intent上设置一个Action,Category或Flag,它将模拟重新打开应用程序进程,就好像是由用户完成但是在新的Intent/Activity上?
编辑:澄清最后一个问题(虽然看起来我的婴儿对Android的理解让我失望所以它可能没有意义):我是否可以在Intent上设置Action,Category或Flag,就像上面的代码段一样,这将允许我确定应用程序进程是否已被操作系统杀死?
android android-intent android-notifications android-pendingintent android-os-handler
在Java中使用synchronized关键字全部在单个对象和线程中.
我可以调用一个调用非同步方法的同步方法来调用同步方法,而不会阻止第一个同步方法完成的最终同步方法吗?