ImageView充气错误

时间:2018-02-06 07:14:53

标签: android android-imageview

我在尝试启动应用时出现此问题。我引用一些博客但没有得到正确的解决方案。 我试图在Android版本4.1.1中运行应用程序但是 面对这个错误。 在5.0.0及以下的高级版本中完全没问题

这是错误:

(可能是由于 ic_cancel 可绘制资源而发生此错误,而且它是矢量绘图)

 FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fontchanger.pixsterstudio/com.fontchanger.pixsterstudio.Activity.DashBoard}: android.view.InflateException: Binary XML file line #178: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

这是我的布局代码:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".Activity.DashBoard">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/blurrel">
    <include layout="@layout/toolbar_new"
        android:id="@+id/toolbar"/>
    <ImageView
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:id="@+id/blink"
        android:layout_margin="15dp"
        android:visibility="gone"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:id="@+id/scrollEdt"
        android:orientation="vertical">
        <com.fontchanger.pixsterstudio.Custome.CustomRegularEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/edtType"
            android:layout_margin="10dp"
            android:inputType="textMultiLine|textNoSuggestions"
            android:textSize="20sp"
            android:background="@drawable/ractangle_line"
            android:lines="5"
            android:gravity="top"
            android:padding="16dp"
            android:textColor="@android:color/black"
            android:hint="Type hear..."
            android:fitsSystemWindows="true"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="9"
            android:layout_below="@+id/edtType">
            <com.fontchanger.pixsterstudio.Custome.CustomSemiBoldTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/txtNew"
                android:text="New"
                android:padding="10dp"
                android:gravity="center"
                android:textSize="18dp"
                android:layout_weight="3"/>

            <com.fontchanger.pixsterstudio.Custome.CustomSemiBoldTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/txtCopy"
                android:text="Copy"
                android:padding="10dp"
                android:gravity="center"
                android:textSize="18dp"
                android:layout_weight="3"/>
            <com.fontchanger.pixsterstudio.Custome.CustomSemiBoldTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/txtSave"
                android:text="Save"
                android:padding="10dp"
                android:gravity="center"
                android:textSize="18dp"
                android:layout_weight="3"/>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/linTemp"
        android:layout_alignParentBottom="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linerNavigation"
            android:orientation="horizontal"
            android:background="@color/green1"
            android:weightSum="10"
            android:transitionName="simple_activity_transition"
            tools:ignore="UnusedAttribute">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:id="@+id/imgList"
                android:layout_margin="12dp"
                android:src="@drawable/list"
                android:layout_weight="2"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:id="@+id/imgEdit"
                android:layout_margin="12dp"
                android:src="@drawable/pencile"
                android:layout_weight="2"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:id="@+id/imgEmoji"
                android:layout_margin="12dp"
                android:src="@drawable/emoji"
                android:layout_weight="2"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:layout_margin="12dp"
                android:id="@+id/imgHistory"
                android:src="@drawable/history"
                android:layout_weight="2"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:id="@+id/imgShare"
                android:layout_margin="12dp"
                android:src="@drawable/share"
                android:layout_weight="2"/>
        </LinearLayout>
        <ListView
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:id="@+id/lvFont"
            android:visibility="gone"/>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/lvSaveList"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:visibility="gone" />
        <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
            android:id="@+id/txtNoData"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_gravity="center"
            android:gravity="center"
            android:padding="10dp"
            android:text="Recent list is empty."
            android:textSize="20dp"
            android:visibility="gone" />
    </LinearLayout>
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/relTransparent"
        android:background="#cc000000"
        android:visibility="gone">
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:id="@+id/imgCancel"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_cancel"
            android:layout_margin="10dp"
            tools:ignore="VectorDrawableCompat" />
        <ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_below="@+id/imgCancel"
            android:fillViewport="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp">
            <com.fontchanger.pixsterstudio.Custome.CustomSemiBoldTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Backspace is not working smoothly in this font."
                android:textColor="@color/white"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:textSize="20dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="This is mostly due to lack of unicode support in this android version, this issue might be solved automatically in future version of android."
                android:textColor="#AEB6BF"
                android:paddingRight="5dp"
                android:paddingLeft="5dp"
                android:textSize="18dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomSemiBoldTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="But there are few workaround which can help : "
                android:textColor="@color/white"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:textSize="20dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="• Either select individual letter which you want to erase"
                android:textColor="#AEB6BF"
                android:paddingRight="5dp"
                android:paddingLeft="5dp"
                android:textSize="18dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="• If you want to remove everything you have to select new"
                android:textColor="#AEB6BF"
                android:paddingRight="5dp"
                android:paddingLeft="5dp"
                android:textSize="18dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="• Combine working font with non-working one, and erase non working fonts as well"
                android:textColor="#AEB6BF"
                android:paddingRight="5dp"
                android:paddingLeft="5dp"
                android:textSize="18dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="• Some non-working fonts can be erased by holding the erase button from the keypad continuously"
                android:textColor="#AEB6BF"
                android:paddingRight="5dp"
                android:paddingLeft="5dp"
                android:textSize="18dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomSemiBoldTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Important Notes : "
                android:textColor="@color/white"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:textSize="20dp"/>
            <com.fontchanger.pixsterstudio.Custome.CustomRegularTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="If you use working font with non working font, it may happen that the whole appearance changes."
                android:textColor="#AEB6BF"
                android:paddingRight="5dp"
                android:paddingLeft="5dp"
                android:textSize="18dp"/>
            </LinearLayout>
        </ScrollView>
    </RelativeLayout>
</RelativeLayout>

如果有任何解决方案请分享。         谢谢

1 个答案:

答案 0 :(得分:-1)

检查您的Imageview的ID与您从findviewbyid或BindView获取的ID相同,并且ID应与您正在膨胀的布局相同。 如果出现更多问题,请粘贴代码。