当inputType="textPassword"时。在华为9.0手机上Toast不能显示,如下
需要做如下两步:
1.在配置文件中digits限制其可输入的内容
2.在代码中做判断,根据华为9.0机型然后做特殊处理
if (ModelUtils.isEMUI() && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
mPwdEt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
mPwdEt.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
附上机型判断的代码如下
public class ModelUtils {
public static boolean isMIUI() {
String manufacturer = Build.MANUFACTURER;
if ("xiaomi".equalsIgnoreCase(manufacturer)) {
return true;
}
return false;
}
public static boolean isEMUI() {
String manufacturer = Build.MANUFACTURER;
if ("HUAWEI".equalsIgnoreCase(manufacturer)) {
return true;
}
return false;
}
public static boolean isOPPO() {
String manufacturer = Build.MANUFACTURER;
if ("OPPO".equalsIgnoreCase(manufacturer)) {
return true;
}
return false;
}
public static boolean isVIVO() {
String manufacturer = Build.MANUFACTURER;
if ("vivo".equalsIgnoreCase(manufacturer)) {
return true;
}
return false;
}
/**
* 获取当前手机系统版本号
*
* @return 系统版本号
*/
public static int getSystemVersion() {
return Integer.parseInt(Build.VERSION.RELEASE);
}
}