Android 如何让EditText不自动获取焦点

设置监听软键盘事件,有点 调用 clearFouse()方法,但是测试了都没有! xml中也找不到相应的属性可以关闭这个默认行为

解决之道:在EditText的父级控件中找一个,设置成    android:focusable="true"      android:focusableInTouchMode="true" 这样,就把EditText默认的行为截断了!

<LinearLayout 
        style="@style/FillWrapWidgetStyle"
        android:orientation="vertical"
        android:background="@color/black"
        android:gravity="center_horizontal"
        
        android:focusable="true"  
        android:focusableInTouchMode="true"
        >
        <ImageView
            android:id="@+id/logo"
            style="@style/WrapContentWidgetStyle"
            android:background="@drawable/dream_dictionary_logo"
          />
        <RelativeLayout 
            style="@style/FillWrapWidgetStyle"
            android:background="@drawable/searchbar_bg"
            android:gravity="center_vertical"
            >
            <EditText
                android:id="@+id/searchEditText"
               style="@style/WrapContentWidgetStyle"
               android:background="@null"
               android:hint="Search"
               android:layout_marginLeft="40dp"
               android:singleLine="true"
             />
            
        </RelativeLayout>
        
    </LinearLayout>

参考原文:http://blog.csdn.net/chenshijun0101/article/details/20362483

posted @ 2014-10-10 18:09  Michelle's Home  阅读(382)  评论(0编辑  收藏  举报