M
M
mib2016-11-11 00:14:06
Android
mib, 2016-11-11 00:14:06

Xamarin.android ToggleSoftInput how to make FullScreen?

Hello
, I need to show the software keyboard without losing the full-screen mode when the navigation and status bar are removed from the screen, but something doesn't work. The same thing happens as when calling Dialog or alert - system controls appear. How to avoid it?
here are the pieces of my code

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
  public static Activity MyActivity;
  protected override void OnCreate(Bundle bundle)
  {
    base.OnCreate(bundle);
    MyActivity = this; //костыль для имплементации интерфейса, который покажет клавиатуру
    View decorView = Window.DecorView;
    var uiOptions = (int)decorView.SystemUiVisibility;
    int newUiOptions = (int)uiOptions;

    newUiOptions |= (int)SystemUiFlags.LayoutStable;
    newUiOptions |= (int)SystemUiFlags.LayoutHideNavigation;
    newUiOptions |= (int)SystemUiFlags.LayoutFullscreen;

    newUiOptions |= (int)SystemUiFlags.HideNavigation;
    newUiOptions |= (int)SystemUiFlags.Fullscreen;
    newUiOptions |= (int)SystemUiFlags.ImmersiveSticky;

    decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;
  // Это переводит приложение в полноэкранный режим, где спрятаны все элементы управления
  }
}

Then I add the implementation of the interface showing the keys in android (and later in ios)
public class CMyKeyboardShower: IMyKeyboardShower
{
  public void ShowKeyboard()
  {
    InputMethodManager inputMethodManager = MainActivity.MyActivity.GetSystemService(Context.InputMethodService) as InputMethodManager;
    inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
//клавиатура появляется и возвращает системные элементы экрана
  }
}

In principle, the same thing happens if you just call a dialogue
MainActivity.MyActivity.RunOnUiThread(() =>
{
  var alert = new AlertDialog.Builder(MainActivity.MyActivity);
  alert.SetView(MainActivity.me_act.LayoutInflater.Inflate(Resource.Layout.layout1, null));
  alert.Create().Show();
});

I would be glad for a hint on how to intercept / disable the appearance of system elements
Thank you!
There is an idea that this is impossible due to the fundamental device of the android, but for example, chrome:
f4297c7b4b844b6283f7aff864acd291.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Belov, 2017-02-03
@verdex

h3 {
margin: 0;
}

https://jsfiddle.net/83dnadce/1/

S
Sergey Goryachev, 2017-02-03
@webirus

This is how it is done correctly - https://jsfiddle.net/webirus/83dnadce/3/
You need to set normalize.css or reset.css , then you won't have to crutch each indent separately.
Otherwise, the layout will be crooked, and you will get tired of editing in every place.
cf2ab12e02b54206ac83dfe86e3735b8.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question