0
我有一个编辑的文字如下定义:android:imeActionLabel和android:imeOptions在所有设备上都不受尊重。
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/loginColorPrimaryDark" />
</android.support.design.widget.TextInputLayout>
在操作按钮,我要开始登录:
edt_password.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(textView.getWindowToken(),
InputMethodManager.RESULT_UNCHANGED_SHOWN);
attemptLogin();
return true;
}
return false;
}
});
虽然在Nexus 5的设备都工作正常,在索尼设备我得到以下几点:
所以无论是android:imeActionLabel="@string/action_sign_in_short"
也不是android:imeOptions="actionUnspecified"
正在得到推崇。我很惊讶,我没有自己指定,我在Android Studio中创建项目时在项目模板中选择了一个Login Activity。似乎它坏了!