1

I have long form (LinearLayout as root) which consist of EditTexts and TextView. Now Issue i am facing is : After clicking the Edit Text, if i clicking on textviews then the focus of an edit text is not clearing. Hence, screen scroll to that edit text due to focus.

I have tried solution - android:focusableInTouchMode="true" in parent layout but no luck.

enter image description here

I have attached an image showing an issue. I have clicked on consulting doctor field which is a TextView but focus is till on email Edit text.

Please help me with some solution. Thanks.

young_08
  • 1,196
  • 2
  • 13
  • 35

2 Answers2

0

After clicking the Edit Text, if i clicking on textviews then the focus of an edit text is not clearing. Hence, screen scroll to that edit text due to focus.

Wrap your EditText inside FrameLayout as shown below

<FrameLayout

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:descendantFocusability="beforeDescendants"
        android:focusable="true"
        android:focusableInTouchMode="true">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </FrameLayout>
Darish
  • 11,032
  • 5
  • 50
  • 70
  • But there are more than one editext and texview (Like form) in random manner. If i wrap every editText inside frame layout than it would make layout mess up. what say? – young_08 Jun 14 '17 at 06:59
  • Yes, You need to wrap up every EditText individually. – Darish Jun 14 '17 at 07:01
0

public static void hideSoftKeyboard (View view)

{

InputMethodManager imm = InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);

}

//Call this method on textview click

Bosco Sabin
  • 124
  • 7