4
0

More than 3 years have passed since last update.

【Android】EditTextで日本語入力⇔英語入力の相互切替ハンドリングは難しい

Last updated at Posted at 2020-06-29

初めに

すみません、解決策を提示する内容ではないです。

Emailアドレスの入力時は
inputType:textEmailAddress
で英字入力モード
テキスト入力時はを初期表示にしたい
inputType:text
で日本語入力モードを初期表示にしたい
と格闘し、結論無理と行き着きました。。

非常に時間を浪費し、悲しみを覚えたので、同じような悩みを抱えて嵌り続ける方がもしいたら早めに切り上げるよう共有したくメモします。
いやいや出来るよ!という賢者がいらっしゃったら是非ご教示下さい。。

事象

以下のように、
TextInputEditTextにを指定して初期のソフトキーボードを英字入力にしようとしたのですが、
別のEditText等で日本語入力に切り替わると、以降inputType:textEmailAddressの初期表示も日本語入力になってしまいます。

activity_main.xml
<com.google.android.material.textfield.TextInputLayout
  android:id="@+id/login_input_email_layer"
  android:layout_width="335dp"
  android:layout_height="wrap_content"
  android:layout_marginTop="15dp"
  android:minHeight="60dp"
  app:layout_constraintEnd_toEndOf="parent"
  app:layout_constraintHorizontal_bias="0.5"
  app:layout_constraintStart_toStartOf="parent"
  app:layout_constraintTop_toBottomOf="@+id/login_error_message_layer">

      <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/login_input_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="@string/login_email_placeholder"
        android:inputType="textEmailAddress" // 何故か効かない。。。
        android:textColor="@color/font_color_black"
        android:textSize="22sp"
        android:maxLength="50"
        android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>

image.png

最後に

内容がなく恐縮です。。
InputFilterを使用してせめてメールアドレス形式のみ入力可能にしようかと思いましたが、
ユーザビリティがかなり下がったので見送りました。
いつか日本語も正しくハンドリング出来るようになると嬉しいですね。。
海外企業なので厳しいでしょうけど。。。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0