我在片段中使用滚动视图,但是当键盘按原样显示时屏幕没有向上滚动。这是场景:我有 mainActivity,它有底部导航栏和一个框架布局,它用作活动的容器。这是代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity"
>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<android.support.design.widget.BottomNavigationView
android:background="@color/clear_white"
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
app:itemIconTint="@color/blue_navbar_icon"
app:itemTextColor="@color/blue_navbar_icon"
app:menu="@menu/navigation" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
片段屏幕有一些输入字段和按钮,它们包裹在约束布局中,然后约束布局包裹在 scrollView 中,以便在键盘处于活动状态时可以向上滚动。这是片段xml文件的代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<include
android:id="@+id/app_bar_new"
layout="@layout/app_bar_new"
app:layout_constraintBottom_toTopOf="@+id/btn_get_location"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_get_location"
style="@style/btn_style"
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="11dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
android:layout_marginStart="11dp"
android:layout_marginTop="12dp"
android:text="@string/get_location_btn_str"
app:layout_constraintBottom_toTopOf="@+id/tv_long"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/app_bar_new" />
<EditText
android:id="@+id/et_name_of_attr"
style="@style/input_field_style"
android:layout_width="0dp"
android:layout_height="47dp"
android:layout_marginBottom="7dp"
android:layout_marginEnd="11dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp" …
Run Code Online (Sandbox Code Playgroud) 我想在 IOS Simulator 上运行我的应用程序 flutter App,但它无限显示“正在运行 pod install...”
我试图找到解决方案,但找不到任何解决方案。
这是我的可可豆荚自动生成的豆荚文件:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| …
Run Code Online (Sandbox Code Playgroud) 我想做的事
当用户点击通知托盘中的 fcm 通知时,我想导航到特定屏幕。
我的代码
我遵循了与 pub.dev 上提到的 6.0.9 版完全相同的说明。
这是我的实现:
_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
print('@onMessage: $message');
},
onResume: (Map<String, dynamic> message) async {
print('@onResume: $message');
Navigator.push(context,
MaterialPageRoute(builder: (context) => NotificationsScreen()));
},
onLaunch: (Map<String, dynamic> message) async {
print('@onLaunch: $message');
Navigator.push(context,
MaterialPageRoute(builder: (context) => NotificationsScreen()));
});
Run Code Online (Sandbox Code Playgroud)
插件版本: firebase_messaging:^6.0.9
我还添加了这些配置:
应用程序/build.gradle:
implementation 'com.google.firebase:firebase-messaging:20.1.0'
项目/build.gradle:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:'1.3.50'"
classpath 'com.google.gms:google-services:4.3.3'
Run Code Online (Sandbox Code Playgroud)
预期输出
当用户点击背景中的通知时,将调用 onResume 或 onLaunch 回调并将其重定向到上述屏幕。
实际产量
当应用程序在前台时正确调用 onMessage 时,不会调用 onResume 和 onLaunch。