-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
魅族设备 TextInputLayout 崩溃 #11
Comments
我这里有一个(可能的)解决方案,同时不会有log警告和功能不全: package android.support.design.widget
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.widget.TextView
class FixedTextInputEditText(context: Context, attrs: AttributeSet?) : TextInputEditText(context, attrs) {
override fun getHint(): CharSequence? {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return super.getHint()
}
return try {
getSuperHintHack()
} catch (e: Exception) {
super.getHint()
}
}
private fun getSuperHintHack(): CharSequence? {
val f = TextView::class.java.getDeclaredField("mHint")
f.isAccessible = true
return f.get(this) as? CharSequence
}
} |
Greetings from Russian developers =) Thank you for this solution, it really works. I`am using MX6 as my main device and found that issue while testing new project. Only your type of workaround helped me. |
And another thanks from Ukrainian developers :) |
Java version of the code from @mariotaku , code specific for Meizu devices only, I think it's safer this way, for the problems the java reflection can bring. Good job @mariotaku |
Thanks for the explanations and workarounds! In my own project, I've tried out a different workaround, which doesn't use reflection. It's still a bit hacky though 😄
private void hackFixHintsForMeizu(TextInputEditText... editTexts) {
String manufacturer = Build.MANUFACTURER.toUpperCase(Locale.US);
if (manufacturer.contains("MEIZU")) {
for (TextInputEditText editText : editTexts) {
editText.setHintTextColor(Color.TRANSPARENT);
editText.setHint(editText.getHint());
}
}
} |
把 <android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="...">
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout> |
This was just fixed in the material components for Android lib, see: material-components/material-components-android#358 |
这个issue是不是已经被修复了?我在mx6上重现不出来 |
TextInputLayout 内嵌 TextInputEditText 例如:
正常展示页面
应用崩溃
MEIZU E3 7.1.1
MX6 6.0
将
android.support.design.widget.TextInputEditText
更换为android.support.v7.widget.AppCompatEditText
不再闪退相关 so 链接: https://stackoverflow.com/questions/51891415/nullpointerexception-on-meizu-devices-in-editor-updatecursorpositionmz/52001305
The text was updated successfully, but these errors were encountered: