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中的向量 –