Q:

Custom EditText losing focus when adding a Spinner to the layout

I have a Layout with Custom SLiders with EditText.SoftKeyboard with inputType Number pops up when we have to edit something in EditText of the SLider.
Everything was working until I added a Spinner inside the layout, now the Edit Text is losing focus that means SoftKeyboard with inputType Number does not pop up when I try to Edit.
If I commit the Java Code for setting Spinner,EditText works fine.
I have tried many things like adjustPanSize in Manifest, using request focus ,changing parent layout to LinearLayout,nothing seems to work.
I am pasting the xml below and the Java Code Sample below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_gradient">

    <include
        android:id="@+id/custom_action_bar"
        layout="@layout/custom_action_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/action_bar_height" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/buttonLayout"
        android:layout_below="@+id/custom_action_bar"
        android:fadeScrollbars="false"
        android:isScrollContainer="false"
        android:scrollbarSize="@dimen/scrollbar_size"
        android:scrollbarThumbVertical="@drawable/scrollbar">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/screen_bottom_spacing"
            android:paddingLeft="@dimen/screen_left_right_spacing"
            android:paddingRight="@dimen/screen_left_right_spacing"
            android:paddingTop="@dimen/screen_top_spacing">

            <include
                android:id="@+id/feature_header"
                layout="@layout/feature_header" />

            <!-- Occupancy enabled -->
            <RelativeLayout
                android:id="@+id/occupancy_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/feature_header">

                <RelativeLayout
                    android:id="@+id/occupancy_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/field_task_margin_top"
                    android:orientation="horizontal">

                    <com.philips.simpleset.view.PhilipsTextView
                        android:id="@+id/occupancy_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentStart="true"
                        android:layout_centerVertical="true"
                        android:text="@string/simple_sensor_occupancy_enabled"
                        android:textColor="@color/title_color"
                        android:textSize="@dimen/id_text_size"
                        app:fontStyle="medium" />

                    <CheckBox
                        android:id="@+id/occupancy_checkBox"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:button="@drawable/checkbox" />
                </RelativeLayout>
            </RelativeLayout>

            <!-- Daylight based control -->
            <RelativeLayout
                android:id="@+id/daylight_based_control_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/occupancy_container">

                <RelativeLayout
                    android:id="@+id/daylight_based_control_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/field_task_margin_top"
                    android:orientation="horizontal">

                    <com.philips.simpleset.view.PhilipsTextView
                        android:id="@+id/daylight_based_control_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentStart="true"
                        android:layout_centerVertical="true"
                        android:text="@string/simple_sensor_daylight_based_control"
                        android:textColor="@color/title_color"
                        android:textSize="@dimen/id_text_size"
                        app:fontStyle="medium" />

                    <CheckBox
                        android:id="@+id/daylight_based_control_checkBox"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:button="@drawable/checkbox" />
                </RelativeLayout>

            </RelativeLayout>

            <!-- Led Indicator -->
            <RelativeLayout
                android:id="@+id/led_indicator_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/daylight_based_control_container">

                <RelativeLayout
                    android:id="@+id/led_indicator_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/field_task_margin_top"
                    android:orientation="horizontal">

                    <com.philips.simpleset.view.PhilipsTextView
                        android:id="@+id/led_indicator_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentStart="true"
                        android:layout_centerVertical="true"
                        android:text="@string/simple_sensor_led_indicator"
                        android:textColor="@color/title_color"
                        android:textSize="@dimen/id_text_size"
                        app:fontStyle="medium" />

                    <CheckBox
                        android:id="@+id/led_indicator_checkBox"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:button="@drawable/checkbox" />
                </RelativeLayout>

            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/occupancy_mode_layout"
                android:layout_below="@+id/led_indicator_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <com.philips.simpleset.view.PhilipsTextView
                    android:id="@+id/occupancy_mode_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_centerVertical="true"
                    android:text="@string/occupancy_mode_title"
                    android:textColor="@color/title_color"
                    android:textSize="@dimen/id_text_size"
                    app:fontStyle="medium" />

                <Spinner
                    android:id="@+id/occupancy_mode_spinner"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/field_task_margin_top_spinner"
                    android:layout_below="@+id/occupancy_mode_title" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/sensor_direct_input_slider_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/slider_margin_top"
                android:layout_below="@+id/occupancy_mode_layout">

                <com.philips.simpleset.view.PhilipsDirectInputSlider
                    android:id="@+id/field_task_tuning_direct_input_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/slider_margin_top" />

                <com.philips.simpleset.view.PhilipsDirectInputSlider
                    android:id="@+id/eco_level_direct_input_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/field_task_tuning_direct_input_slider"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/field_task_margin_top" />

                <com.philips.simpleset.view.PhilipsDirectInputSlider
                    android:id="@+id/background_light_level_direct_input_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/eco_level_direct_input_slider"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/field_task_margin_top" />

                <com.philips.simpleset.view.PhilipsDirectInputSlider
                    android:id="@+id/hold_time_direct_input_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/background_light_level_direct_input_slider"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/field_task_margin_top" />

                <com.philips.simpleset.view.PhilipsDirectInputSlider
                    android:id="@+id/prolong_time_direct_input_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/hold_time_direct_input_slider"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/field_task_margin_top" />

                <com.philips.simpleset.view.PhilipsDirectInputSlider
                    android:id="@+id/grace_fading_direct_input_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/prolong_time_direct_input_slider"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/field_task_margin_top" />

            </RelativeLayout>

        </RelativeLayout>
    </ScrollView>

    <!--Buttons-->
    <LinearLayout
        android:id="@+id/buttonLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:paddingBottom="@dimen/screen_bottom_spacing"
        android:paddingLeft="@dimen/screen_left_right_spacing"
        android:paddingRight="@dimen/screen_left_right_spacing"
        android:paddingTop="@dimen/screen_top_spacing">

        <com.philips.simpleset.view.PhilipsButton
            android:id="@+id/back_btn"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="0dp"
            android:layout_height="@dimen/philips_button_height"
            android:layout_marginEnd="@dimen/philips_button_horizontal_spacing"
            android:layout_weight="1"
            android:background="@drawable/philips_button"
            android:text="@string/back"
            android:textColor="@color/custom_button_text_color_light"
            android:textSize="@dimen/philips_button_text_size"
            app:fontStyle="regular" />

        <com.philips.simpleset.view.PhilipsButton
            android:id="@+id/next_btn"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="0dp"
            android:layout_height="@dimen/philips_button_height"
            android:layout_weight="1"
            android:background="@drawable/philips_button"
            android:text="@string/confirm"
            android:textColor="@color/custom_button_text_color_light"
            android:textSize="@dimen/philips_button_text_size"
            app:fontStyle="regular" />

    </LinearLayout>
</RelativeLayout>

Java Code goes here:
  private void initializeView(com.philips.simpleset.core.device.Device device) {

        if (NfcAppApplication.getCurrentSubAppType() == SubAppType.EASYSENSE) {
            if (device != null) {
                textViewUniqueDeviceId.setText(editableProfile.getUniqueId().replaceAll("..(?!$)", "$0 "));
            }
            imageViewSelectedLuminaire.setImageResource(R.drawable.simple_sensor_icon);
            textViewUniqueDeviceId.setVisibility(device == null ? View.GONE : View.VISIBLE);
            textViewUniqueDeviceIdTitle.setVisibility(device == null ? View.GONE : View.VISIBLE);
            directInputSliderEcoLevel.setVisibility(View.GONE);
            layoutOccupancyMode.setVisibility(View.GONE);
        } else {
            textViewUniqueDeviceIdTitle.setVisibility(View.GONE);
            textViewUniqueDeviceId.setVisibility(View.GONE);
        }
        imageViewSelectedLuminaire.setImageResource(R.drawable.simple_sensor_icon);
        directInputSliderFieldTaskTuning.setMin(MIN_FIELD_TASK_TUNING_VALUE);
        directInputSliderFieldTaskTuning.setMax(MAX_FIELD_TASK_TUNING_VALUE);
        directInputSliderFieldTaskTuning.setSliderUnit("%");
        directInputSliderFieldTaskTuning.setSliderLabel(getString(R.string.simple_sensor_field_task_tuning));

        directInputSliderHoldTime.setMax(MAX_HOLD_TIME);
        directInputSliderHoldTime.setMin(MIN_HOLD_TIME_SLIDER);
        directInputSliderHoldTime.setMultiplier(0.5);
        directInputSliderHoldTime.setSliderUnit("min");
        directInputSliderHoldTime.setSliderLabel(getString(R.string.simple_sensor_hold_time));

        directInputSliderProlongTime.setMaxTextViewPresenter(new PhilipsSlider.MaxTextViewPresenter() {
            @Override
            public String updateTextView() {
                return "Infinite";
            }
        });
        directInputSliderProlongTime.setMax(MAX_PROLONG_TIME_SLIDER);
        directInputSliderProlongTime.setMin(MIN_PROLONG_TIME_SLIDER);
        directInputSliderProlongTime.setSliderUnit("min");
        directInputSliderProlongTime.setSliderLabel(getString(R.string.simple_sensor_prolong_time));

        directInputSliderBackgroundLightLevel.setMax(MAX_BACKGROUND_LIGHT_LEVEL_SLIDER);
        directInputSliderBackgroundLightLevel.setMin(MIN_BACKGROUND_LIGHT_LEVEL_SLIDER);
        directInputSliderBackgroundLightLevel.setSliderUnit("%");
        directInputSliderBackgroundLightLevel.setSliderLabel(getString(R.string.simple_sensor_background_light_level));

        directInputSliderGraceFading.setMax(MAX_GRACE_FADING_SLIDER);
        directInputSliderGraceFading.setMin(MIN_GRACE_FADING_SLIDER);
        directInputSliderGraceFading.setSliderUnit("s");
        directInputSliderGraceFading.setSliderLabel(getString(R.string.simple_sensor_grace_fading));

        directInputSliderEcoLevel.setMax(MAX_ECO_LEVEL_SLIDER);
        directInputSliderEcoLevel.setMin(MIN_ECO_LEVEL_SLIDER);
        directInputSliderEcoLevel.setSliderUnit("%");
        directInputSliderEcoLevel.setSliderLabel(getString(R.string.eco_level_title));

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.occupancy_values, R.layout.spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerOccupancyMode.setAdapter(adapter);
        spinnerOccupancyMode.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                spinnerOccupancyMode.setSelection(position);
                occupancyMode = position;
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        spinnerOccupancyMode.setSelection(DEFAULT_OCCUPANCY_MODE);
    }

A:

Its rather strange but true! Spinner custom layout has an issue, using a standard xml from android solved the problem.

