Lunchbox
Lunchbox

Reputation: 1550

Android Screen moves to edit text that has focus

in my activity I have multiple edit texts, and some animated sliders with buttons beneath them. The problem is when I open a slider and tap on the button, the screen "jumps" back up to the first edit text. How can I stop this from happening? I just want the screen to stay where it was after the button press. Any help will be appreciated.

EDIT/UPDATE I just played around with an iPhone. Would it rather be possible to remove focus from the edit text when the soft keyboard is minimized? (Removing the focus would work in regards to the original question of the screen navigating to the top by its self)

Upvotes: 0

Views: 1148

Answers (3)

Lunchbox
Lunchbox

Reputation: 1550

I used the following solution. I created a method:

public void clearFocusOnEditText(){
    //editText.clearfocus()
}

I then added this method to my ontouch() and onClick() methods. I'm guessing this is not the best solution, but for all intents and purposes it works brilliantly.

Upvotes: 0

WISHY
WISHY

Reputation: 11999

add it in your manifest to the activity tag

   android:windowSoftInputMode="stateHidden"

Upvotes: -1

6thSigma
6thSigma

Reputation: 248

Add the following to your parent layout (i.e. LinearLayout, RelativeLayout, etc.)

android:focusableInTouchMode="true"

Upvotes: 2

Related Questions