TL; DR:使用上一个TextView简单android:drawableLeft
功能导致崩溃图片旁边的图片?
的TextView
是Android的最基本的视觉元素之一。那为什么它最基本的功能不起作用?
https://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableLeft
我的代码很简单,它是使用图像的自定义对话框旁边TextView
:
<TextView
android:text="Text next to check mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView19"
android:drawableLeft="@drawable/ic_check_circle_white_24dp"
android:textSize="24sp"
android:textStyle="normal|bold"/>
的代码提供了可视化编辑器惊人的结果:
但是当程序实际上是ex ecuted,简单android:drawableLeft
功能崩溃的应用程序:
android.view.InflateException: Binary XML file line #64: Error inflating class TextView
我尝试打开该对话框,如下所示:
dialog = new Dialog(this,R.style.Theme_AppCompat_Light_Dialog_Alert);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.premium_dialog);
dialog.setCanceledOnTouchOutside(false);
dialog.getWindow().setLayout((int) (getResources().getDisplayMetrics().widthPixels * 0.90), (int) (getResources().getDisplayMetrics().heightPixels * 0.90));
dialog.show();
为什么说这样的基本功能InflateException
的原因? (我知道这是导致该问题的drawableLeft
函数,因为当我删除TextView时,错误消失)
从完整的堆栈跟踪在那里你用'造成的:android.content.res.Resources $ NotFoundException:文件** RES /绘制/ abc_dialog_material_background.xml **从颜色状态列表资源ID#0x7f020011' –
不能在较低API的'Textview'中直接使用'vectordrwable'。创建CustomTextview以支持向下API中的向量 –