2016-07-27 57 views
0

这是我的EditText,textCapWords不适用于三星键盘。 (三星S4)。有没有解决方法?textCapWords不适用于三星键盘

<EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="16dp" 
     android:background="@android:color/transparent" 
     android:imeOptions="actionDone" 
     android:inputType="textCapWords" 
     android:maxLength="15" 
     android:padding="12dp" 
     android:textSize="20sp" /> 

回答

1

在XML试试这个:

android:textAllCaps="true" 
+1

txtAllCaps和textCapWords是不同的东西 –

+0

textCapCharacters在Android 7三星键盘上停止工作。所以你从我那里得到一个投票,即使不是所要求的:) – Moth

0

使用该部分设备的键盘不支持capWords或禁止设置

该代码EDITTEXT每个单词的第一个字母大写

youredittext.addTextChangedListener(new TextWatcher() { 
     @Override 
     public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { 

     } 

     @Override 
     public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { 

     } 

     @Override 
     public void afterTextChanged(Editable editable) { 
      String capitalizedText = WordUtils.capitalize(youredittext.getText().toString()); 
      if (!capitalizedText.equals(youredittext.getText().toString())) { 
       youredittext.addTextChangedListener(new TextWatcher() { 
        int mStart = 0; 
        @Override 
        public void beforeTextChanged(CharSequence s, int start, int count, int after) { 

        } 

        @Override 
        public void onTextChanged(CharSequence s, int start, int before, int count) { 
         mStart = start + count; 
        } 

        @Override 
        public void afterTextChanged(Editable s) { 
         youredittext.setSelection(mStart); 
         youredittext.removeTextChangedListener(this); 
        } 
       }); 
       youredittext.setText(capitalizedText); 
      } 
     } 
    }); 

下载JAR导入WordUtils

https://www.dropbox.com/s/olfjyhfrghxvfs2/orgwordutils.jar?dl=0

1

你尝试编程?

youredttxt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); 

OR

android:inputType="textCapWords|textCapSentences" 

OR

AFAIK这一个已被弃用,但我不知道将它的工作或没有,但你可以尝试,

​​
0

可以试试这个...为我工作...

android:inputType="textCapWords" 

或者

android:inputType="textCapSentences" 

或者

android:inputType="textCapWords" 

对于三星S5/S7有用于制作第一承租人的帽子在一个名为 “自动大写” 设置的其他设置。

相关问题