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 /> 就無法得到游標閃爍的效果。