Android RTL password fields?

前端 未结 6 1686
别跟我提以往
别跟我提以往 2020-12-09 08:58

It appears that if you have an EditText on android with the

android:inputType=\"textPassword\" or android:password=\"true

fields

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 09:15

    If you put inputType = textPassword or set a passwordTransformation method on EditText, text direction is taken as LTR. It means RTL for password is discouraged. You need to write custom TextView to override this behaviour.

    Code snippet from android source for TextView.

    // PasswordTransformationMethod always have LTR text direction heuristics returned by
            // getTextDirectionHeuristic, needs reset
            mTextDir = getTextDirectionHeuristic();
    
    
    protected TextDirectionHeuristic getTextDirectionHeuristic() {
            if (hasPasswordTransformationMethod()) {
                // passwords fields should be LTR
                return TextDirectionHeuristics.LTR;
            }
    

提交回复
热议问题