Android 需要防止我的AutoCompleteTextView在活动开始时获得焦点

Android 需要防止我的AutoCompleteTextView在活动开始时获得焦点,android,focus,autocompletetextview,Android,Focus,Autocompletetextview,我的XML文件中有一个AutoCompleteTextView: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/

我的XML文件中有一个AutoCompleteTextView:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.android.aashima.premiumpoint.PremiumPoint">

        <AutoCompleteTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/searchByName"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:padding="10dp"
        android:background="#ddd"
        android:hint="Search By Name"
        android:textColorHint="#fff"
        android:gravity="center"
        android:layout_alignTop="@+id/searchImageButton"
        android:layout_alignBottom="@+id/searchImageButton"
        android:layout_toLeftOf="@+id/searchImageButton"
        android:textColor="#fff"
        android:completionThreshold="1"
        android:imeOptions="actionDone"
        android:dropDownWidth="fill_parent"/>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/searchImageButton"
        android:src="@drawable/search40"
        android:layout_alignParentRight="true"
        android:padding="2dp"
        android:background="@color/material_blue_grey_950"/>

    </RelativeLayout>
在我的AutoCompleteTextView上方提供一个虚拟项:

    <!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
    <LinearLayout
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="0px"
        android:layout_height="0px"/>
自动完成文本视图

在搜索过程中,我发现类似以下内容的结果:

android:windowSoftInputMode="stateHidden"
android:windowSoftInputMode="stateUnchanged"
但我想要的是防止它获得焦点,而不是隐藏键盘

我尝试过很多选择,但都没有成功。我做错什么了吗? 提前谢谢

编辑: 还试图:

clearFocus();
requestFocus();

尝试以下两种方法的组合:

<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_width="0px"
    android:layout_height="0px"/>

<AutoCompleteTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/searchByName"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:padding="10dp"
    android:background="#ddd"
    android:hint="Search By Name"
    android:textColorHint="#fff"
    android:gravity="center"
    android:layout_alignTop="@+id/searchImageButton"
    android:layout_alignBottom="@+id/searchImageButton"
    android:layout_toLeftOf="@+id/searchImageButton"
    android:textColor="#fff"
    android:completionThreshold="1"
    android:imeOptions="actionDone"
    android:dropDownWidth="fill_parent"
    android:nextFocusUp="@id/searchByName"
    android:nextFocusLeft="@id/searchByName"/>

当您需要时,反之亦然。

您是否尝试过在其上插入不可见视图?是的。。我在上面提到过,您是否将属性-android:focusableInTouchMode=“true”设置为ScrollView或相对布局
clearFocus();
requestFocus();
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_width="0px"
    android:layout_height="0px"/>

<AutoCompleteTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/searchByName"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:padding="10dp"
    android:background="#ddd"
    android:hint="Search By Name"
    android:textColorHint="#fff"
    android:gravity="center"
    android:layout_alignTop="@+id/searchImageButton"
    android:layout_alignBottom="@+id/searchImageButton"
    android:layout_toLeftOf="@+id/searchImageButton"
    android:textColor="#fff"
    android:completionThreshold="1"
    android:imeOptions="actionDone"
    android:dropDownWidth="fill_parent"
    android:nextFocusUp="@id/searchByName"
    android:nextFocusLeft="@id/searchByName"/>
 dummy.requestFocus();
     search.clearFocus();