I’m working on Xamarin forms project. I’ve many Entry fields in my application, one of them is in popup and the popup opens in the centre of the device screen. Also few entry fields are in scroll view. The issue is only with the Android Application. For iOS it’s working perfectly. When I click on Entry field in side the popup, the soft key board is opened and the UI of my popup gets disturbed. So, I decided to set WindowSoftInputMode = SoftInput.AdjustPan to my main Activity. This solves my UI issue of the popups but now when I click on other entry fields,my ![scroll view stops scrolling] (few entry fields are in side scrollview).I tried by using AdjustResize and rest of other soft inputs, but of no use. Any ideas on how to get rid of this ?
Asked
Active
Viewed 6,218 times
2 Answers
4
On Android Xamarin.Forms Application is working on a single Android Activity, so WindowSoftInputMode
is set globally. You could do a dependency injection service. On iOS it would do nothing and on Android it would set WindowSoftInputMode
to your desired value. Then use it to set WindowSoftInputMode
before and after showing your Popup.
In Xamarin.Forms Forms.Context
is the Activity.
var window = ((Activity)Forms.Context).Window;
window.SetSoftInputMode(SoftInput.AdjustPan);

Daniel Luberda
- 7,374
- 1
- 32
- 40
-1
In case of
Xamarin Android
you can access window directly from mainActivity Like so:
Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan);
or in AndroidManifest.xml
<activity android:name=".myActivity"
android:label="@string/app_name"
android:screenOrientation="sensorPortrait"
android:windowSoftInputMode="adjustPan"/>

Balha
- 17
- 4
-
@Amrut has already tried this approach, but it won't work because it sets it globally, and thus changes the behavior on pages that don't need it. – Chucky Feb 08 '19 at 15:32
-
Would you mind to read my responce again: In case of Xamarin Android, and @Amrut is talking about XF, thanks for the dislike I got a new badge – Balha Jul 25 '19 at 06:48
-
Then why are you giving a Xamarin Android answer to a Xamarin Forms question? – Chucky Jul 25 '19 at 07:13
-
maybe it will help someone – Balha Jul 30 '19 at 08:34