android activity启动的时候隐藏软键盘

1、概述

android如果界面有EditText之类的跳软键盘的控件  在跳转到该界面是默认会跳出软键盘的。

更何况有些需求要直接需要获取焦点

<requestFocus />

如果是EditText就会有光标闪烁效果

该属性的位置:

   <com.rockerhieu.emojicon.EmojiconEditText

        android:id="@+id/upload_title_eidt"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="5dp"

        android:layout_marginTop="5dp"

        android:background="@drawable/upload_white"

        android:hint="标题限30字内"

        android:maxLength="30"

        android:paddingLeft="10dp"

        android:textColor="@color/black"

        android:textColorHint="@color/new_share_conten_user_name"

        android:textSize="@dimen/header_layout_right_text_size"

        emojicon:emojiconSize="20sp" >


        <requestFocus />

    </com.rockerhieu.emojicon.EmojiconEditText>




2、为了增强用户体验,有时候不需要一进入就跳软键盘

a)、最方便的解决方式:

AndroidMainFest.xml文件中配置

android:windowSoftInputMode="stateHidden" 

或者

android:windowSoftInputMode="adjustPan"

区别见:http://blog.csdn.net/yunnywu/article/details/7926015


b)、

在能获取到软键盘的控件的父级布局设置

  android:focusable="true"
  android:focusableInTouchMode="true"

副作用:就是EditText  没有了焦点,如果设置了<requestFocus />  就无法得到光标闪烁的效果。



posted @ 2014-09-12 11:12  也行  阅读(6347)  评论(0编辑  收藏  举报