I have an XML layout which is used for rendering all the fragments dynamically in the view pager scroll view and in the fragment layout i have a Edit Text Box and when i click on the edit text in the second or thrid fragment immediately the keyboad opens and foucs is changed to the first fragment edit box.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/custom_border"
android:orientation="vertical"
android:id="@+id/parent">
<RelativeLayout
android:id="@+id/fragmentPageTitle"
android:layout_width="match_parent"
android:layout_height="44dp"
android:orientation="horizontal">
<TextView
android:id="@+id/fragment_header_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginStart="10dip"
android:text="Header"
android:textColor="#000"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp">
<ImageButton
android:id="@+id/ibClose"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@color/transparent"
android:padding="10dp"
android:src="@drawable/ic_button_close"
android:visibility="gone" />
<TextView
android:id="@+id/gCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dip"
android:text="123"
android:textColor="@color/inforGray6"
android:textSize="16dp"
android:textStyle="bold"
android:visibility="gone"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/parent_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/footer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:visibility="visible">
<EditText
android:layout_width="150dp"
android:layout_height="40dp"
android:textColor="#000000"/>
</LinearLayout>
<ScrollView
android:id="@+id/mainscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red"
android:visibility="visible"
android:layout_above="@+id/footer_layout"
android:layout_below="@+id/search_layout">
</ScrollView>
</RelativeLayout>
</LinearLayout>
Using the scroll view layout to addView() the final layout in the UI is rendered and when setting the scroolview visibility to gone then only text field renders on ui and focus change is not happening.