我有一个customEdittext扩展了emojieDittext,该emojiedittext扩展了appcompatedittext并派生https://github.com/vanniktech/emoji库。
我曾经为CustomEdittext撰写撰写tyettext样式。但是,如果我添加此样式,应用程序将崩溃。请帮助我。
我的递观样式:
<style name="ComposeEditText" parent="@style/Widget.AppCompat.EditText">
<item name="android:padding">2dp</item>
<item name="android:background">@null</item>
<item name="android:maxLines">4</item>
<item name="android:maxLength">2000</item>
<item name="android:capitalize">sentences</item>
<item name="android:autoText">true</item>
<item name="android:gravity">center_vertical</item>
<item name="android:imeOptions">flagNoEnterAction</item>
<item name="android:inputType">textAutoCorrect|textCapSentences|textMultiLine</item>
</style>
我在xml中的递观:
<com.android.android.util.view.CustomEditText
android:id="@+id/editText"
style="@style/ComposeEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
app:emojiSize="@dimen/emojiSize" />
代码:
public class CustomEditText extends EmojiEditText {
public CustomEditText(Context context) {
super(context);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
}
}
错误日志:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.android.android/com.android.android.conversation.a.PRofile}:
android.view.InflateException: Binary XML file line #0:
Binary XML file line #0: Error inflating class com.android.android.util.view.CustomEditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.android.android.util.view.CustomEditText
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.android.android.util.view.CustomEditText
Caused by: java.lang.reflect.InvocationTargetException
查看您的 CustomEditText
是EmojiEditText
,请尝试将您的样式的parent
设置为表情符号的样式。我认为问题是您的风格是从错误的样式继承
我只是删除"@style/",然后解决。谢谢您的帮助
而不是
<style name="ComposeEditText" parent="@style/Widget.AppCompat.EditText">
使用
<style name="ComposeEditText" parent="Widget.AppCompat.EditText">