5

I have two EditText views and one ImageView. My goal is to hide the ImageView when i am showing the keyboard (When the user have clicked on one of the EditText fields)

Then show the imageView again when the user have unfocused the EditText field or the keyboard is not visible anymore.

I have tried tons of different ways to do this. But nothing really works as intended. Do you guys have any idea how i could achieve this

Jemil Riahi
  • 1,260
  • 2
  • 18
  • 34

4 Answers4

2

Have you tried to detect if the keyboard is opened ? How do I Detect if Software Keyboard is Visible on Android Device?

Make debug and when is opened try to hide image . imageview.setvisibility (GONE) if it does not work you can try to change layout

Make 2 layouts and switch visibility if the keyboard is open /closed

Community
  • 1
  • 1
Raluca Lucaci
  • 1,868
  • 2
  • 17
  • 35
0

You can add a OnFocusChangeListener to the EditText,when you click the EditText,it will get focus,and then you can hide the ImageView.

wngxao
  • 76
  • 5
  • 2
    The problem is that it never gets unfocused when you hit the backbutton. So the keyboard have disappeared and the EditText is still focused – Jemil Riahi Mar 01 '16 at 09:54
  • If so,then you can override the onBackPressed method to show the ImageView. – wngxao Mar 01 '16 at 09:58
  • 1
    Yeah then i have to do some kind of unfocus onBackPress. Thought about that aswell. But was hoping for a cleaner solution. – Jemil Riahi Mar 01 '16 at 10:04
-2

<activity android:name="SearchResultsActivity" android:windowSoftInputMode="adjustPan"/>

adjustPan: The activity’s main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

regards! :)

jmorales
  • 35
  • 3
-7

You can do one thing, place UIView-> UIImageView -> UITextfield1-> UITextField2.Handle the UIImageView hiding state in textfield delegates which are Begin and End editing delegate methods