Search result for Question Taged android-softkeyboard
There are some results of your Tag: android-softkeyboard
    Show entire bottom sheet with EditText above Keyboard

    1. FAILURE
    2. implementing a UI where a bottom sheet will appear above the keyboard with an EditText for the user to enter a value. The problem is the View is being partially overlapped by the keyboard, covering up the bottom of the bottom sheet.

    3. Most common Solution
    4. Just reposting @jblejder from this question Keyboard hides BottomSheetDialogFragment since it worked for me, to make it easier for others to find:

      The most convenient way that I found to change this is by creating style:

      <style name="DialogStyle" parent="Theme.Design.Light.BottomSheetDialog">
          <item name="android:windowIsFloating">false</item>
          <item name="android:statusBarColor">@android:color/transparent</item>
          <item name="android:windowSoftInputMode">adjustResize</item>
      </style>
      

      And set this in onCreate method of your BottomSheetDialogFragment:

      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogStyle)
      }
      

      This is how it looks on my device:

      enter image description here

      ==== UPDATE ====

      As already mentioned in the Comments a few times, you might also need to set the state of the BottomSheetDialog to STATE_EXPANDED like in Nordknight's answer below

      dialog = new BottomSheetDialog(getContext(), R.style.BottomSheetDialog);  
      dialog.setOnShowListener(new DialogInterface.OnShowListener() {
      @Override
      public void onShow(DialogInterface dialog) {
                  new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          BottomSheetDialog d = (BottomSheetDialog) dialog;
                          FrameLayout bottomSheet = d.findViewById(R.id.design_bottom_sheet);
                          BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
                          bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                      }
                  },0);
              }
          });
      

    5. Solution 2
    6. This might be a redundant answer. Although just pointing out the issue. If you're using BottomSheetDialogFragment, the only way is to enable the attribute android:windowIsFloating to true. This will enable the whole window to be on top of whatever is trying to take the space behind it.

      <style name="BottomSheetDialogThemeNoFloating" parent="Theme.Design.Light.BottomSheetDialog">
              <item name="android:windowIsFloating">false</item>
              <item name="android:windowSoftInputMode">adjustResize|stateVisible</item>
      </style>
      

      Then in your onCreate() of your dialog, set this style.

      override fun onCreate(savedInstanceState: Bundle?) {
              super.onCreate(savedInstanceState)
              // set the window no floating style
              setStyle(DialogFragment.STYLE_NORMAL, R.style.AppRoundedBottomSheetDialogThemeNoFloating)
      }
      

      This is handy for those who frequently use bottom sheets and may want to deal with EditText and soft keyboard overlapping each other.

      Note: The class KeyboardUtil by mikepenz has an issue in which on certain phones, the content view with input field is automatically pushed above keyboard despite giving bottom padding to the whole content view supplied.

    7. Solution 3
    8. dialog = new BottomSheetDialog(getContext(), R.style.BottomSheetDialog);  
      dialog.setOnShowListener(new DialogInterface.OnShowListener() {
      @Override
      public void onShow(DialogInterface dialog) {
                  new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          BottomSheetDialog d = (BottomSheetDialog) dialog;
                          FrameLayout bottomSheet = d.findViewById(R.id.design_bottom_sheet);
                          BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
                          bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                      }
                  },0);
              }
          });
      

      This code works fine at Fragment's onCreateView method (thanks for ADM)

    9. Solution 4
    10. Some answers seem to do the trick better than others but will need modification when using the new material design components instead of the older support libraries while also using kotlin

      Hope this will help someone.

      BottomSheetDialog(this, R.style.DialogStyle).apply {
          setContentView(layoutInflater.inflate(R.layout.bottom_sheet, null))
          window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
          findViewById<EditText>(R.id.time_et)?.requestFocus()
      
          show()
      }
      

      layout/bottom_sheet.xml

      <?xml version="1.0" encoding="utf-8"?>
      <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="#ffffff"
              android:padding="16dp">
      
          <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical">
      
      
              <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal">
      
                  <View
                          android:layout_width="0dp"
                          android:layout_height="match_parent"
                          android:layout_weight="1" />
      
                  <LinearLayout
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_weight="5"
                          android:orientation="vertical">
      
                      <TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Time"
                              android:textColor="#000000"
                              android:textSize="24sp"
                              android:textStyle="bold" />
      
                      <LinearLayout
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginTop="8dp"
                              android:orientation="horizontal">
      
                          <EditText
                                  android:id="@+id/time_et"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:inputType="numberSigned"
                                  android:minWidth="50dp"
                                  android:text="15" />
      
                          <TextView
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginLeft="8dp"
                                  android:text="min" />
      
                      </LinearLayout>
      
      
                  </LinearLayout>
      
              </LinearLayout>
      
      
              <Button
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="16dp"
                      android:background="#000"
                      android:text="Save"
                      android:textColor="#fff" />
      
          </LinearLayout>
      
      </ScrollView>
      

      styes.xml (Split for v-21 for using statusBarColor)

          <style name="DialogStyle" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
              <item name="android:windowIsFloating">false</item>
              <item name="android:statusBarColor">@android:color/transparent</item>
              <item name="android:windowSoftInputMode">adjustResize</item>
          </style>
      
    Salvatrix Ngải 2022-08-11
    How to move the layout up when the soft keyboard is shown android

    I have a login screen with two EditTexts and a login button in my layout. The problem is that, when I start typing, the soft keyboard is shown and covers the login button. How can I push the layout up or above the keyboard when it appears?

    I do not want to use a ScrollView, just want to implement it without scrolling down. Please, suggest me some way of doing it. Thanks in advance.

    Hari Ionas 2022-08-17
    android - How to show soft-keyboard when edittext is focused

    I want to automatically show the soft-keyboard when an EditText is focused (if the device does not have a physical keyboard) and I have two problems:

    1. When my Activity is displayed, my EditText is focused but the keyboard is not displayed, I need to click again on it to show the keyboard (it should be displayed when my Activity is displayed).

    2. And when I click done on the keyboard, the keyboard is dissmissed but the EditText stays focused and y don't want (because my edit is done).

    To resume, my problem is to have something more like on the iPhone: which keep the keyboard sync with my EditText state (focused / not focused) and of course does not present a soft-keyboard if there is a physical one.

    Vimal Anderson 2022-08-14
    android - Hide soft keyboard after dialog dismiss

    I want to hide soft keyboard after AlertDialog dismiss, but it's still visible. Here is my code:

    alert = new AlertDialog.Builder(MyActivity.this);
    imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    
    alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
    
        @Override
        public void onDismiss(DialogInterface dialog) {
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        }
    });
    
    Vlastimila Zhanna 2022-08-21
    How to close/hide the Android soft keyboard programmatically?

    I have an EditText and a Button in my layout.

    After writing in the edit field and clicking on the Button, I want to hide the virtual keyboard when touching it outside the keyboard. I assume that this is a simple piece of code, but where can I find an example of it?

    Edna Morgen 2022-08-12
    android - How to hide the BottomNavigationView below keyboard with adjustResize set

    According to the material design spec, when the keyboard appears, the BottomNavigationView should hide underneath it. However, if I set android:windowSoftInputMode="adjustResize" in the Activity's manifest then the BottomNavigationView moves above the keyboard.

    I need to set adjustResize to enable scrolling to the bottom of the screen while the keyboard is open. However, I do not want the BottomNavigationView to be visible. Can this be done?

    How it currently looks:

    enter image description here

    The layout XML (in reality there would be a FrameLayout where the EditText is and the EditText would be inside it):

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Input"
            android:layout_gravity="center"
            android:layout_centerVertical="true"/>
    
        <android.support.design.widget.BottomNavigationView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            app:itemBackground="@color/colorPrimary"
            app:menu="@menu/menu_bottom_navigation"
            app:itemIconTint="@android:color/white"
            app:itemTextColor="@android:color/white"/>
    
    </RelativeLayout>
    
    Corwin Stanislav 2022-08-20
    Disabling the keyboard's send button when nothing has been typed yet [Android]

    I'm creating a search option in an android application.

    After pressing "Search" on the screen-keyboard an event triggers which sends the query to the server. What I want to do is disable the "Search" button on the screen-keyboard when no text has been typed in it's corresponding EditText yet.

    I added this to the EditText:

    android:imeOptions="actionSearch"

    So that's why the keyboard has got a "Search" button in stead of the default "enter"/"done". (Just in case you where wondering).

    Rupa Luned 2022-09-07
    Android Use Done button on Keyboard to click button

    Ok in my app I have a field for the user to input a number. I have the field set to only accept numbers. When the user clicks on the field it brings up the keyboard. On the keyboard (on ICS) there is a done button. I would like for the done button on the keyboard to trigger the submit button i have in my application. My code is as follows.

    package com.michaelpeerman.probability;
    
    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnCancelListener;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.Message;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import java.util.Random;
    
    public class ProbabilityActivity extends Activity implements OnClickListener {
    
    private Button submit;
    ProgressDialog dialog;
    int increment;
    Thread background;
    int heads = 0;
    int tails = 0;
    
    public void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.main);
        submit = ((Button) findViewById(R.id.submit));
        submit.setOnClickListener(this);
    }
    
    public void onClick(View view) {
        increment = 1;
        dialog = new ProgressDialog(this);
        dialog.setCancelable(true);
        dialog.setMessage("Flipping Coin...");
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        EditText max = (EditText) findViewById(R.id.number);
        int maximum = Integer.parseInt(max.getText().toString());
        dialog.setMax(maximum);
        dialog.show();
        dialog.setOnCancelListener(new OnCancelListener(){
    
              public void onCancel(DialogInterface dialog) {
    
                  background.interrupt();
                  TextView result = (TextView) findViewById(R.id.result);
                    result.setText("heads : " + heads + "\ntails : " + tails);
    
    
              }});
    
    
        background = new Thread(new Runnable() {
            public void run() {
                heads=0;
                tails=0;
                for (int j = 0; !Thread.interrupted() && j < dialog.getMax(); j++) {
                    int i = 1 + new Random().nextInt(2);
                    if (i == 1)
                        heads++;
                    if (i == 2)
                        tails++;
                    progressHandler.sendMessage(progressHandler.obtainMessage());
                }
            }
        });
        background.start();
    }
    
    Handler progressHandler = new Handler() {
        public void handleMessage(Message msg) {
    
            dialog.incrementProgressBy(increment);
            if (dialog.getProgress() == dialog.getMax()) {
                dialog.dismiss();
                TextView result = (TextView) findViewById(R.id.result);
                result.setText("heads : " + heads + "\ntails : " + tails);
    
    
            }
        }
    
    };
    
    }
    
    Marianne Alf 2022-08-15
    Android: how to make keyboard enter button say "Search" and handle its click?

    I can't figure this out. Some apps have an EditText (textbox) with the help of which, when you touch it and it brings up the on-screen keyboard, the keyboard has a "Search" button instead of an enter key.

    I want to implement this. How can I implement that Search button and detect the press of the Search button?

    Edit: found how to implement the Search button; in XML, android:imeOptions="actionSearch" or in Java, EditTextSample.setImeOptions(EditorInfo.IME_ACTION_SEARCH);. But how do I handle the user pressing that Search button? Does it have something to do with android:imeActionId?

    Jana Lailoken 2022-08-14
    java - Android: How to push button above soft keyboard

    I've got a "save" button which I want to push up together with the soft keyboard. So when the user clicks an EditText in my layout, then the button has to stay above the keyboard. Now the button becomes hidden underneath the keyboard. How do you do this?

    Thanks in advance!

    Nadra Serapion 2022-08-18
    android - How to set windowsoftinputmode programmatically from Fragments?

    I have a requirement in which I have one MainActivity. From this activity I instantiate 4 fragments(Let us say FragmentA, FragmentB, FragmentC, FragmentD.

    Out of these four Fragments; on 3 Fragments(Let us say FragmentA, FragmentB, FragmentC), I want to set MainActivity's windowsoftinputmode() to SOFT_INPUT_ADJUST_PAN so that window can resize.

    And on one Fragment()let us say FragmentD), I want to set MainActivity's windowsoftinputmode() to SOFT_INPUT_ADJUST_NOTHING.

    So what I do is, on each Fragment's onViewCreated() method I execute the following line of code with changing LayoutParams flag:

    ((MainActivity)getActivity()).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
    

    or

    ((MainActivity)getActivity()).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    

    Problem is that it not working and I am not able to setSoftInputMode correctly and I can not prevent window getting resized.

    Same lines of code works perfectly when I execute them in onCreate() of MainActivity as shown :

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    

    But than the value is set for all four fragments. My MainActivity declaration in manifest is :

    <activity
        android:name="com.test.MainActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"/>
    

    Can somebody help what I am doing wrong in this. I want to have behaviour different for different Fragments.

    Adrijan Kazue 2022-09-08
    java - Hide keyboard when navigating from a fragment to another

    I have a Fragment that contains an Edit Text. When the Edit Text is pressed, the keyboard is being shown. When pressed the Save button in the upper corner, the application returns to the previous fragment, but the keyboard persists.

    I would like the keyboard to be hidden when navigating to the previous fragment.

    Please, note that I tried this solution: Close/hide the Android Soft Keyboard.

    InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(myView.getWindowToken(), 0);
    

    I tried to use this in both fragments, in the onCreate method.

    I also tried to hide the soft keyboard in the layout:

    android:windowSoftInputMode="stateAlwaysHidden"
    

    None of these worked, unfortunately.

    I would have posted some pictures, but I do not have enough reputation yet. I would appreciate any constructive help and opinion and do not forget that "A wise man can learn more from a foolish question than a fool can learn from a wise answer." :)

    Regards, Alexandra

    Gert Branimira 2022-08-21
    android - How to keep a bottom nav bar from being pushed up on keyboard shown

    How can i create a sticky footer that wont be moved up with the view when the softkey keyboard popups up?

    Below is an image example of my current setup and what i want to achieve. I have a scrollview that contains my page content and a linearlayout that is aligned to the parent bottom that acts as a nav bar.

    Example of what i want it to do

    Problem is that when the keyboard popups, it pushes my entire view up, including the bottom nav section. I do not want to disable the automatic pushing up of the view (by setting android:windowSoftInputMode="adjustPan") but rather exclude a single element from being pushed up, my bottom nav bar.

    I have tested the windowSoftInputMode fix but it hides my page content behind the keyboard. Is there a way to have it continue pushing up the scrollview but not the bottom nav? My other option was to set visibility:gone on keyboard up and then reshow it on keyboard down, but that seems overly complicated and not always reliable from what i read.

    If anyone has any examples or suggestions, i'm all ears. Thanks.

    Sitora Meresankh 2022-08-23
    android - Push up content except some view when keyboard shown

    I have a layout that contains 5 EditText and a Button and a TextView at bottom. Now when I press an EditText then the keyboard will shown and all my View is push up.

    Now I don't want to push my TextView and Button to above keyboard, just only want to push up all EditText inside ScrollView to above keyboard.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#ff0"
            >
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
    
                <EditText
                    android:layout_marginTop="30dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="EditText 1"
    
                    />
    
                <EditText
                    android:layout_marginTop="30dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="EditText 2"
                    />
    
                <EditText
                    android:layout_marginTop="30dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="EditText 3"
                    />
    
                <EditText
                    android:layout_marginTop="30dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="EditText 4"
                    />
    
                <EditText
                    android:layout_marginTop="30dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="EditText 5"
                    android:inputType="textNoSuggestions"
                    />
    
            </LinearLayout>
    
        </ScrollView>
    
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:text="Button"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000"
            android:text="I don't want to push this TextView and Button to above keyboard when keyboard is shown. Just obly want to push the ScrollView that contain all EditText"
            />
    </LinearLayout>
    

    enter image description here

    I have an idea is. When I will listener when keyboard show and hide. When keyboard show I will set the bottom margin of ScrollView = keyboard height, when keyboard hide I will set this margin = 0.
    Is there any way easier to handle my case? Any help or suggestion would be great appreciated.

    UPDATE
    If I use windowSoftInputMode=adjustPan => not all EditText is push up to above keyboard
    If I use windowSoftInputMode=adjustResize => Button, TextView and all EditText is push up to above keyboard

    Meino Suvi 2022-08-30
    Soft keyboard open and close listener in an activity in Android

    I have an Activity where there are 5 EditTexts. When the user clicks on the first EditText, the soft keyboard opens to enter some value in it. I want to set some other View's visibility to Gone when the soft keyboard opens and also when the user clicks on the first EditText and also when the soft keyboard closes from the same EditText on the back button press. Then I want to set some other View's visibility to visible.

    Is there any listener or callback or any hack for when the soft keyboard opens from a click on the first EditText in Android?

    Naliaka Dipika 2022-08-15
    How to hide Android soft keyboard on EditText

    I have an Activity with some EditText fields and some buttons as a convenience for what normally would be used to populate those fields. However when we the user touches one of the EditText fields the Android soft keyboard automatically appears. I want it to remain hidden by default, unless the user long presses the menu button. I have search for a solution to this and found several answers, but so far I can't get them to work.

    I have tried the following:

    1 - In the onCreate method,

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    

    2 - Also in the onCreate method,

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
    

    3 - and fIn the Manifest file,

    <activity android:name=".activityName" android:windowSoftInputMode="stateAlwaysHidden"/>
    

    None of these methods work. Whenever the user clicks on the EditText field, the soft keyboard appears. I only want the soft keyboard to appear if the user explicitly shows it by long pressing the menu key.

    Why isn't this working?

    Simon Yitro 2022-08-20
    android - Use "ENTER" key on softkeyboard instead of clicking button

    Hello I've got a searched EditText and search Button. When I type the searched text, I'd like to use ENTER key on softkeyboard instead of search Button to activate search function.

    Thanks for help in advance.

    Magdalena Naseer 2022-08-17
    How to close Android Soft KeyBoard programmatically?

    I am currently showing softkeyboard using the following code

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput (InputMethodManager.SHOW_FORCED, InputMethodManager.RESULT_HIDDEN);
    

    And Here I d'not bind the softkeyboard with Edittext because of that I had used the above code.

    Now I want to close the SoftKeyboard so i am currently using the below code but it is not working.

    imm.toggleSoftInput (InputMethodManager.SHOW_FORCED, InputMethodManager.RESULT_HIDDEN);
    

    Can Anyone suggest me what to use for closing the softKeyboard ?


    Based on Below Answer I want to let you clear that I am not using EditText, I use Layout on which I want to show Keyboard and Hide keyboard. I want to send keyboard key event to remote area bcoz of that I didnot used editText.

    Benjamín Murali 2022-08-20
    android - Is it possible to always show the action bar when using adjustPan as soft input mode?

    In my application I have a ListView with a footer that contains a custom view with an EditText inside. At the top sits an action bar. The activity currently uses SOFT_INPUT_ADJUST_RESIZE (adjustResize) as soft input mode and does not close the keyboard when scrolling.

    To show more of the list I wanted to remove the keyboard when scrolling and to get a smoother scrolling behavior I want to change so that SOFT_INPUT_ADJUST_PAN (adjustPan) is used. However, if I change to adjustPan, the whole view, including the action bar, is pushed up. I'd like the list view to be pushed but the action bar stay at the top at all times. Is that possible to do? If not, is it possible to use adjustResize and get a smooth resize animation?

    So far I have tried:

    • Requesting Window.FEATURE_ACTION_BAR_OVERLAY, but that did not help although the documentation sounded promising.
    • Moving around the action bar container depending on if the soft keyboard is visible or not, which ended up looking like a massively unstable hack so I scrapped it.
    • So far I have ruled out adjustResize, due to the drawing behavior that happens when scrolling, minimizing the keyboard and resizing the listview at the same time. Is there a way to make a smooth animated resize?
    Baptist Slaven 2022-09-06
    Android adjustpan not working after the first time

    My problem: starting from the second time the software keyboard is shown on the screen, it entirely hides my EditText.

    Attribute android:windowSoftInputMode="adjustPan" has been specified in the AndroidManifest.xml, but it works only the first time.

    I have the following layout:

     <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="464dp"
            android:gravity="top"
            android:orientation="vertical"
            android:paddingLeft="16dp"
            android:paddingRight="16dp" >
    
            <ListView
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="10"
                android:background="#E3E3E2"
                android:gravity="top" />
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <EditText
                    android:id="@+id/addListText"
                    android:layout_width="0dp"
                    android:layout_height="48dp"
                    android:layout_weight="10"
                    android:contentDescription="@string/addItemContentDescription"
                    android:gravity="bottom|center_horizontal"
                    android:inputType="textLongMessage"
                    android:textColor="#E3E3E2"
                    android:visibility="gone" />
    
                <ImageButton
                    android:id="@+id/addTextListButton"
                    android:layout_width="0dp"
                    android:layout_height="48dp"
                    android:layout_weight="1"
                    android:layout_gravity="right"
                    android:background="@android:color/transparent"
                    android:contentDescription="@string/addItemButton"
                    android:scaleType="fitCenter"
                    android:src="@drawable/plus_add"
                    android:visibility="gone" />
            </LinearLayout>
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:gravity="bottom|center_horizontal"
            android:orientation="horizontal"
            android:paddingLeft="16dp"
            android:paddingRight="16dp" >
    
            <ImageButton
                android:id="@+id/syncListsButton"
                android:layout_width="64dp"
                android:layout_height="match_parent"
                android:src="@android:drawable/ic_popup_sync" />
    
            <ImageButton
                android:id="@+id/showOrHide"
                android:layout_width="64dp"
                android:layout_height="match_parent" />
    
            <ImageButton
                android:id="@+id/delListButton"
                android:layout_width="64dp"
                android:layout_height="match_parent"
                android:src="@android:drawable/ic_menu_delete" />
        </LinearLayout>
    </LinearLayout>
    

    The "showOrHide" button shows/hides the "addListText"/"addTextListButton" combo.

    When the EditText is shown for the first time and I touch it, the soft keyboard appears on the screen and the "addListText"/"addTextListButton" combo is panned correctly. When I hide the keyboard and then show it again, the keyboard covers completely my addListText editbox!

    Any idea on what's going on? I'm testing it on Android 4.2.2.

    Please help! Thanks :-)

    edit: I've also tried to put the first LinearLayout inside a ScrollView but it doesn't work!

    Orion Waman 2022-08-22
    android - Soft keyboard hides half of EditText

    I have a ListView and the last list item contains EditText:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <RelativeLayout
            android:id="@+id/contentLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="30dp"
            android:orientation="vertical" >
    
            <ImageView
                android:id="@+id/test"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignRight="@+id/messageEditText"
                android:layout_below="@+id/messageEditText"
                android:layout_marginRight="14dp"
                android:src="@drawable/test" />
    
            <EditText
                android:id="@+id/messageEditText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_toLeftOf="@+id/sendImageButton"
                android:ems="10"
                android:gravity="top"
                android:hint="@string/messageEditText"
                android:inputType="textMultiLine"
                android:minHeight="55dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp" />
    
            <ImageButton
                android:id="@+id/sendImageButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/messageEditText"
                android:layout_alignParentRight="true"
                android:layout_alignTop="@id/messageEditText"
                android:adjustViewBounds="true"
                android:maxHeight="55dp"
                android:maxWidth="55dp"
                android:padding="12dp"
                android:scaleType="centerInside"
                android:src="@drawable/sendmessage" />
    
        </RelativeLayout>
    </RelativeLayout>
    

    Half of the EditText is hidden. I also can't scroll ListView. Any solution?

    image

    Marianne Alf 2022-08-31
    android - Recyclerview not scrolling to end when keyboard opens

    I am using recylerview in my application and whenever new element is added to recyclerview, it scrolls to last element by using

    recyclerView.scrollToPosition(adapter.getCount());
    

    But, whenever keyboard opens(because of editTextView), it resizes the view and recyclerview gets smaller, but couldn't scroll to last element.

    android:windowSoftInputMode="adjustResize"
    

    I even tried to used the following code to scroll to last element, but it didn't work

    editTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    recyclerView.scrollToPosition(chatAdapter.getItemCount());
                }
            }
        });
    

    I can try adjustPan to shift the pan up, but it is hiding my toolbar. Please suggest any way to rectify the issue.

    Ganesh Quique 2022-08-19
    android - How to stop Soft keyboard showing automatically when focus is changed (OnStart event)

    I am developing for a tablet using Android 2.2.

    I have a form which I am using for new and editable instances. When editable, I want to stop the user from editing certain fields. I manage this in my onStart-event, setting the txt.setFocusableInTouchMode(false). This forces the focus to the next focusable EditText in my form (which is great), but when running, the soft keyboard automatically appears for the EditText with the focus. Anybody know how to stop this?

    Here's the code (called in the onStart event):

    private void PopulateFields(){
        TextView txtTitle = (TextView) this.findViewById(R.id.txtEquipmentEditTitle);
        AutoCompleteTextView txtMake = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditMake);
        AutoCompleteTextView txtModel = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditModel);
        EditText txtDesc = (EditText) this.findViewById(R.id.txtEquipmentEditDesc);
        TextView txtDeptKey = (TextView) this.findViewById(R.id.txtEquipmentEditDeptKey);
        EditText txtSerial = (EditText) this.findViewById(R.id.txtEquipmentEditSerialNo);
        EditText txtBarCode = (EditText) this.findViewById(R.id.txtEquipmentEditBarCode);
    
        txtTitle.setText("Edit Equipment");
        txtMake.setText(make);
        txtModel.setText(model);
        txtDesc.setText(desc);
        txtDeptKey.setText(Integer.toString(deptKey));
        txtSerial.setText(serial);
        txtBarCode.setText(barCode);
        txtMake.setEnabled(false);
        txtModel.setEnabled(false);
        txtDesc.setEnabled(false);
        txtMake.setClickable(false);
        txtMake.setFocusableInTouchMode(false);
        txtModel.setFocusableInTouchMode(false);
        txtDesc.setFocusableInTouchMode(false);
        txtMake.setFocusable(false);
        txtModel.setFocusable(false);
        txtDesc.setFocusable(false);
    }
    
    Kyle Elkins 2022-08-27
    android - WebView hides soft keyboard during loadUrl(), which means a keyboard cannot stay open while calling javascript

    Since the way you call javascript on a WebView is through loadUrl("javascript: ... "); The keyboard cannot stay open.

    The loadUrl() method calls loadUrlImpl() , which calls a method called clearHelpers() which then calls clearTextEntry(), which then calls hideSoftKeyboard() and then we become oh so lonely as the keyboard goes away.

    As far as I can see all of those are private and cannot be overridden.

    Has anyone found a workaround for this? Is there a way to force the keyboard to stay open or to call the javascript directly without going through loadUrl()?

    Is there anyway to override the WebView in a way to prevent (the private method) clearTextEntry() from being called?

    Kyle Elkins 2022-09-11
    Android on-screen keyboard auto popping up

    One of my apps has an "opening screen" (basically a menu) that has an EditText followed by several Buttons. The problem is that several of my users are reporting that when they open the app it's automatically popping up the on-screen keyboard without them even touching the EditText. As far as I can tell, all of these users are using the HTC Hero.

    Is this a bug in 1.5? Is there anything I can do about it?

    Fabian Mirela 2022-08-15
    Only show number buttons on Soft Keyboard in Android?

    On the soft keyboard in Android you can set the soft keyboard to show the numbers instead of a-z keyboard using android:inputType="numberDecimal". However, what do I do if I only want to show the top number row 1 2 3 4 5 6 7 8 9 0 and not the following rows starting with @ # $ % ...?

    Thanx for listening!

    Shayne Misti 2022-08-23
    java - Show soft keyboard for dialog

    I am displaying a dialog with an edittext view. However, the softkeyboard will open only if the user presses inside the editview. So I tried calling an InputMethodManager with the following code.

    InputMethodManager imm =
     (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(dialogField,0);
    

    The dialogField is the input field. However, when exactly am I supposed to do this? I tried it in the onStart() method of the dialog, but nothing happens. I also tried requesting the focus for the dialogField before, but that changes nothing.

    I also tried this code

    dialogField.setOnFocusChangeListener(new View.OnFocusChangeListener()
    {
        public void onFocusChange (View v, boolean hasFocus)
        {
            if (hasFocus)
            {
                Main.log("here");
                dialogInput.getWindow().setSoftInputMode(
                  WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                /*
                    InputMethodManager mgr =
                      (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                    mgr.showSoftInput(dialogField,0);
                */
            }
        }
    });
    

    in both versions. But no soft keyboard would like to appear. The Main.log is just a log, which shows me that the function is actually called. And yes, it is called.

    I could get the keyboard with the SHOW_FORCED flag before the dialog opens. But then it will not close on exit. And I can only do that BEFORE I show the dialog. Inside any callbacks it does not work either.

    Louella Eleonora 2022-08-17
    android - Implementing onKeyPreIme(int keyCode, KeyEvent event) in Fragment

    I cannot figure how to implement onKeyPreIme(int keyCode, KeyEvent event) in a Fragment.

    @Override
    public boolean onKeyPreIme(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && 
            event.getAction() == KeyEvent.ACTION_UP) {
                // do your stuff
                return false;
        }
        return super.dispatchKeyEvent(event);
    }
    

    I tried a lot but nothing works. Also, I could not find anything on Google or Stack Overflow. I would like to perform an action when the back key is pressed and the softkeyboard is up. Setting an onKeyListener on my EditTexts did not work, since KeyEvent.KEYCODE_BACK is not called when the soft keyboard is up. I appreciate any help and source code.

    Iorwerth Endrit 2022-09-02
    android - Set FAB (Floating Action Button) above keyboard

    Already asked here but without a proper answer.

    I want the FAB to float on top of the keyboard. that's it.

    For example

    1. Open a new Blank Activity template project with Android Studio
    2. Change the Hello World TextView to EditText
    3. See image below:

    enter image description here

    Ethan Savitr 2022-08-19
    android - Creating a SoftKeyboard with Multiple/Alternate characters per key

    I've followed the examples on developer.android.com regarding Input Methods and played with the SoftKeyboard sample application. These together give more than enough information regarding the creation of simple keyboard.

    What I can't see in the API is the ability to create alternate / multiple characters per key which is available on the standard Keyboard (LatinIME Keyboard).

    enter image description here

    The above image is the result of a long press on the "a" key. When you long press a key it's possible to populate a popup with alternate characters.

    enter image description here

    It is also possible to give a popup hint on some keys which will prompt the user to press and hold a key in order to get the popup menu.

    So far I haven't found a single source of information on how this is achieved, hopefully someone will be able to give me a head start, until then I'll follow the source code of the inbuilt keyboard and see if I can reverse engineer it.

    Edit: Would help if developer.android.com 's link to the LatinIME Keyboard didn't link to a picture of a Sheep :) Actual source code for LatinIME.java.

    Edit 2: More as a reference than anything else, this is the sequence I believe a usual longPress action goes through in order to show the popup keyboard in KeyboardView.java:

    onTouchEvent()
    onModifiedTouchEvent()
    mHandkler.handleMessage() with MSG_LONGPRESS
    openPopupIfRequired() 
    onLongPress()
    

    Edit 3:

    I still haven't figured this out - How do you add label suggestions to keys? An answer suggests it isn't built into the API and indeed I haven't found the codeto do this. However the Keyboard on 2.3.4 (API 10) shows this functionality being implemented:

    enter image description here

    Would very much like to figure out how IT does it but it isn't anywhere in the onDraw() method that I can see - which makes me believe it's being written outside of the KeyboardView element. I can't however find the layout file used to display the KeyboardView element on the inbuilt keyboard - If anyone knows where to find this perhaps that will give me the clue I need.

    Edit 4: Moved key Preview question here as it's slightly off topic:

    How do you disable the SoftKeyboard key preview window?

    Kyle Elkins 2022-08-21
    android - Unable to show keyboard automatically in the SearchView

    The SearchView is focused by default, but when I try to show software keyboard - it doesn't happen:

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
    

    But when I click on the SearchView - it does. Why?

    Marko Yalwa 2022-08-26