I am using latest version of ionic 2.
My code has a <ion-content padding><form></form></ion-content>
with a text input inside of it. When I try to type something in there on Android the whole page gets pushed upwards by the keyboard.
html file
<ion-content class="login-screen" padding>
<form (ngSubmit)="login()" novalidate>
<ion-list>
<ion-item>
<ion-label fixed>Username</ion-label>
<ion-input type="text" name="username" [(ngModel)]="username" required></ion-input>
</ion-item>
<ion-item>
<ion-label fixed>Password</ion-label>
<ion-input type="password" name="password" [(ngModel)]="password" required></ion-input>
</ion-item>
</ion-list>
<button ion-button full type="submit">Login</button>
</form>
<button ion-button clear full outline type="button" (click)="openModal()">Forgot Password?</button>
</ion-content>
is there any solutions ?
Just add this properties to your ionicModule in app.module.ts. works for me.
Add this method to the .ts on this page
My scenario is: the keyboard is called on this page, but when you return to the previous page, the page will appear as a whole, and I try to solve it with this method, I use ionic2.
there is some issues for inputs and forms with the scrolling like is mentioned here so i recommend wait to the next RC to get that fixed, cause its not your code fault's just ionic bug.
This all should be fixed in the RC4 (soon). That being said, to disable the scroll when input is focused, add this to your config object (in the
@NgModule
):A very good explanation of those two properties can be found here:
You can also use the
ionic-plugin-keyboard
to stop the native browser from pushing/scrolling the content pane up and allow the keyboard to slide over and cover existing content:UPDATE
Just like @Luckylooke mentioned in the comments:
UPDATE II
As of Ionic 3.5.x seems like the keyboard still have some issues. I've found that the following configuration produces a better result (compared with the defaults) from the UI/UX point of view:
By keeping
scrollAssist: true
we avoid the input to be hidden by the keyboard if it's near the bottom of the page, and by settingscrollPadding: false
we also avoid some weird bugs related to an empty white space after hiding the keyboard.