由于工作需要,AutoCompleteTextView在默认下不需要焦点,当用户点击时再获取焦点并显示软键盘。在子布局LinearLayout下添加android:focusable="true"、android:focusableInTouchMode="true"两条语句即可。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal" >
<AutoCompleteTextView
android:id="@+id/tv_poi_input"
style="@style/common_text_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@drawable/poi_search"
android:hint="@string/poi_input"
android:paddingLeft="10dp"/>
<TextView
android:id="@+id/tv_search"
style="@style/common_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_white_selector"
android:gravity="center"
android:text="@string/search" />
</LinearLayout>