The desired effect for my android application is to have a webview with an input box and content. When the user clicks on the keyboard, the keyboard pushes the input box up, but does not resize the main content and just overlays ontop of it as seen in the diagram below.
The problem I'm experiencing is that the keyboard covers the input box and does not push it up.
This is currently a cordova android application. In the manifest, I have configued
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleInstance" android:name="GigJam" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustPan">
Also in the config.xml:
<preference name="Fullscreen" value="false" />
I used android:windowSoftInputMode="adjustPan" to prevent the screen from resizing which is what i want since I don't want the content to be squished. I've also tried configuring the css for the input box to be fixed and absolute (basically tied to the bottom of the webview.
From my understanding, when the keyboard pops up from an edit in the input box, that it would push up the box as well because the input box is constrained to the webview which will be pushed up as well.
Any advice appreciated,
Thanks,
D
Android has a keyboard event that I listen to. When the show/hide is trigger, I grab the active input component and transform the box in the y axis by the size of the keyboard height which can be grab from the event in the listener. I transform back when the show is triggered.
Note: resize needs to be disabled for the android:windowSoftInputMode and set to "adjustPan"
Use this line:
getActivity()
.getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Add android:windowSoftInputMode="adjustResize" to the activity with the webview in the AndroidManifest.xml
For example:
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize" />
Related
Please read the question carefully before any action,
I am using the custom toolbar in my android application with one image, one button, and title.
Now below that, I have a full screen with edit texts and text views and buttons. While I am trying to fill data and keyboard is open at that time while I am scroll down my screen upside, it hides toolbar also, even toolbar is outside of scroll.
I have taken scrollbar inside the body view, not for the whole screen, but then also while I am scrolling it hides the toolbar.
Try this in manifest file it may work.
<activity
android:name=".YourActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
Use in your activity tag in Manifest file
<activity android:windowSoftInputMode="adjustResize"> </activity>
The activity's main window is always resized to make room for the soft keyboard on the screen.
Moreover, you can find the detail about it here official doc
Also, look at this question
Hope it will be helpful to you.
In the layout file of one of my activities I've got 2 inputs at the top and at the bottom and a next button.
The problem is, when keyboard shows, it covers the button. How can I bring the views above keyboard?
Check this blog post On-screen Input Methods
You can use android:windowSoftInputMode attribute to specify what should happen whether the layout is resized or whether it scrolls.
In your manifest file
<activity name=".YourActivity"
android:windowSoftInputMode="stateVisible|adjustResize">
...
</activity>
Related questions:
Move layouts up when soft keyboard is shown?
Push up content when clicking in edit text
Android: How do I prevent the soft keyboard from pushing my view up?
How to move the layout up when the soft keyboard is shown android
How to check visibility of software keyboard in Android?
Just put in manifest..
Use "adjustResize"
It makes main window always resized to make room for the soft keyboard on screen.
<application
......
>
<activity
.............................
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
</application>
I'm building a simple app for android that's taking input from the user via an EditText. But when the EditText is focused and the on screen keyboard appears it causes the whole layout to move a few dps so that the action bar slides under the statusbar. How can i fix the activity so that it doesn't move when the keyboard opens?
Tried this which made it better but it still moves a few dps
View dv=getWindow().getDecorView();
dv.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
Try using adjustResize as your activity's android:windowSoftInputMode. Add the following line in your manifest in that particular activity.
<activity android:windowSoftInputMode="adjustResize">
Also, check the other options available for windowsSoftInputMode.
I have an Activity screen with a form that has a text area, and text below the form. When the screen opens, for some reason, the keyboard pops up automatically and blocks the bottom part of the screen for the user, causing some confusion since they don't get to see the text that is below.
Is there a way to not make the keyboard pop up by default and only have it pop up when the user clicks inside the text area?
Thanks!
In your manifest file use this
<activity
android:name=".YourActivityName"
android:configChanges="keyboardHidden|orientation"
android:windowSoftInputMode="stateHidden" />
Use this attributes on the textarea in your xml file
android:focusable="true"
android:focusableInTouchMode="true"
I am using a tabbed application. There is an EditText my application. When I click on the EditText, the window is getting resized and the virtual keyboard is displaying at the bottom of the window. But the four tabs are displaying at the top of the keyboard.
I do not want to display my tabs, when the keyborad is displaying. Or I do not want to resize my window. My need is just to hide the tabs and other things below the EditText.
I use all options with 'android:windowSoftInputMode' in my manifest. bUT I can not see any differences.
Please give me the solution.
Thank you..
I found the solution.. for specially "sencha/phonegap/cordova" users.
Edit the main activity in android manifest file add this attribute.
android:windowSoftInputMode="adjustNothing"
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:windowSoftInputMode="adjustNothing"
android:label="#string/app_name"
android:launchMode="singleTop"
android:name="com.company.appName.MainActivity"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
When Virtual keyboard comes, the view is not re-sized but it gets moved. See this blog post to prevent this.
See also
Handling keyboard input in Android
I have the same problem and I don't find the blog post suggested by Mudassir helpful. I don't want my window moved or resized or anything so neither adjustPan nor adjustResize works.
I just want it to leave my windows position unchanged.
I found that I can call getWindow and then set the y position and gravity to top|center_horizontal and that fixes it for windows where they don't overlap with the keyboard when the keyboard appears.
For large windows that are partially covered by the keyboard there doesn't seem to be a solution to prevent the keyboard from pushing them around.