无论何时出现键盘,我都希望在ionic4应用程序上启用滚动,而键盘将屏幕上的内容向上推
我尝试将“ android:windowSoftInputMode”设置为“ adjustResize”,还将“ android:windowSoftInputMode”设置为“ adjustPan”。前者仍然推高内容,而后者则不推高内容,而是使键盘覆盖在输入标签上。我还尝试过在键盘出现但仍然无法正常工作时向内容添加滚动。
import {IonContent} from '@ionic/angular';
@ViewChild(IonContent, {read: IonContent, static: true}) myContent:IonContent;
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
public navController: NavController,
public toastController: ToastController,
private location: Location,
private router: Router,
private keyboard: Keyboard
) {
this.initializeApp();
}
ngAfterViewInit() {
window.addEventListener('keyboardDidShow', this.customScroll);
}
customScroll() {
this.myContent.scrollToPoint(0, 100000); // 100 replaced by your value
}
键盘将屏幕上的内容向上推,而不是在键盘覆盖时允许滚动