2

I've got an Activity with fragment and there is an EditText inside that Fragment, I want to be able to write lines of text but software keyboard covers it when EditText grows.

I've seen use of ScrollView, adjustResize and adjustPan, but i don't know why they did'n work!

update:

if i use .beginTransaction().add it works fine but i need to use .beginTransaction().replace and keyboard covers EditText

update 2:

it works fine on android 4.3 but in android 4.4 keyboard covers EditText

What I want:

  1. A layout(containing EditText) that goes above keyboard when it comes up
  2. Smooth scroll in that layout
Community
  • 1
  • 1

3 Answers3

1

To force the soft keyboard to appear, you can use

EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);

To close it you can use

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

Hope it will help you.

Vatsal Shah
  • 547
  • 3
  • 9
  • it's not what i meant. My problem is that when keyboard comes up it covers EditText. –  Feb 12 '15 at 10:00
  • In your manifest file, you need to set the appropriate android:windowSoftInputMode property. This attribute is valid since API 3. – Vatsal Shah Feb 12 '15 at 10:25
  • I've seen use of adjustResize and adjustPan, but i don't know why they did'n work! i'll send my code soon. –  Feb 12 '15 at 10:31
  • Please use in your manifest activity tag – Vatsal Shah Feb 12 '15 at 10:35
1

According to this answer, by setting android:fitsSystemWindows="true" on root element it works fine

Community
  • 1
  • 1
0

There is a lot of problem when you use translucent system bars. I had a similar problem and I found 0 solutions. Try to remove translucent system bars and check if it works fine.

JavierSegoviaCordoba
  • 6,531
  • 9
  • 37
  • 51