在膨胀类IamgeView时出错

时间:2016-06-30 21:01:40

标签: java android android-inflate

我的完整日志跟踪:

06-30 16:29:16.303 30023-30023/pb.myPackage E/AndroidRuntime: FATAL EXCEPTION: main 
Process: pb.myPackage, PID: 30023 
and

roid.view.InflateException: Binary XML file line #128: Error inflating class ImageView 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android

.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at pb.myPackage.FeedFragment$3.onCreateViewHolderImpl(FeedFragment.java:689) 
at com.poliveira.parallaxrecyclerview.ParallaxRecyclerAdapter.onCreateViewHolder(ParallaxRecyclerAdapter.java:132) 
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5482) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4707) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617) 
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994) 
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)


at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353) 
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574) 
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028) 
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906) 
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:596) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055) 
at

 android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1695) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) 
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) 
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at 
android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1091) 
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:801) 
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:815) 
at android.view.View.layout(View.java:14817) 
at android.view.Vi
ewGroup.layout(ViewGroup.java:4631) 
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 
at android.widget.FrameLayout.onLayout(FrameLayout.java:388) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) 
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) 
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 
at android.widget.FrameLayout.onLayout(FrameLayout.java:388) 
at android.view.View.layout(View.java:14817) 
at android.view.ViewGroup.layout(ViewGroup.java:4631) 
at android.widget.LinearLay 
06-30 16:29:16.893 30023-30070/pb.myPackage E/dalvikvm: Could not find class 'java.beans.BeanInfo', referenced from method weborb.reader.AnonymousObject.setFieldsAsBean 
06-30 16:29:16.893 30023-30070/pb.myPackage W/dalvikvm: VFY: unable to resolve check-cast 4167 (Ljava/beans/BeanInfo;) in Lweborb/reader/AnonymousObject; 
06-30 16:29:16.893 30023-30070/pb.myPackage D/dalvikvm: VFY: replacing opcode 0x1f at 0x001f

好的错误是指向第127行,这是一个imageView,我的xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingBottom="2dp">

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/cardview"
    app:cardBackgroundColor="@android:color/white"
    app:cardElevation="2dp"
    app:cardMaxElevation="2dp"
    app:cardUseCompatPadding="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/upperEventView"
            android:background="@drawable/below_border">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="\@will.Smith"
                android:id="@+id/txtViewEventPublisher"
                android:textSize="18dp"
                android:textColor="#ef414c"
                android:textAlignment="textEnd"
                android:maxLines="1"
                android:ellipsize="end"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@+id/eventPublisherImageView"
                android:layout_toEndOf="@+id/eventPublisherImageView"
                android:layout_marginLeft="3dp" />


            <pb.myPackage.CustomImageViewCircularShape
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:id="@+id/eventPublisherImageView"
                android:layout_centerVertical="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="2dp"
                android:layout_marginBottom="2dp"
                android:scaleType="centerCrop"
                android:background="@drawable/circle"
                android:src="@drawable/ryan" />

            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="50dp"
                android:layout_height="40dp"
                android:text="..."
                android:id="@+id/eventButton"
                android:layout_alignTop="@+id/eventPublisherImageView"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:background="#00ffffff"
                android:textColor="#ef414c" />

        </RelativeLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Title "
        android:id="@+id/textViewEventStory"
        android:textSize="17sp"
        android:textColor="#575757"
        android:editable="false"
        android:layout_below="@+id/upperEventView"
        android:layout_margin="5dp" />


        <TextView
    android:id="@+id/listIDTxt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ObjectID "
    android:gravity="center_vertical"
    android:textSize="0sp"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/txtViewTimeStmp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:id="@+id/txtViewImgExistence"
    android:textSize="1dp"
    android:alpha="0" />


        <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_below="@+id/locationLayout"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="#f5f5f5"
            android:layout_marginTop="5dp">
        </android.support.v4.view.ViewPager>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="20dp"
            android:layout_below="@+id/pager">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="15dp"
            android:layout_marginTop="5dp"
            android:layout_centerInParent="true">

            <ImageView
                android:layout_width="7dp"
                android:layout_height="7dp"
                android:id="@+id/indicatorImg1"
                android:src="@drawable/indicator1"
                android:layout_centerVertical="true"
                android:layout_margin="2dp"
                android:layout_gravity="center"
                android:visibility="gone"
                android:contentDescription="" />
            <ImageView
                android:layout_width="7dp"
                android:layout_height="10dp"
                android:id="@+id/indicatorImg2"
                android:layout_alignParentTop="false"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:src="@drawable/indicator2"
                android:layout_centerVertical="true"
                android:layout_margin="2dp"
                android:layout_gravity="center"
                android:visibility="gone" />
            <ImageView
                android:layout_width="7dp"
                android:layout_height="7dp"
                android:id="@+id/indicatorImg3"
                android:layout_alignParentTop="false"
                android:src="@drawable/indicator2"
                android:layout_centerInParent="true"
                android:layout_gravity="center"
                android:layout_margin="2dp"
                android:visibility="gone" />


        </LinearLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="4h"
                android:id="@+id/txtViewTimeStmp"
                android:textSize="15sp"
                android:layout_gravity="right"
                android:textColor="#919191"
                android:layout_alignParentRight="true"
                android:layout_marginRight="3dp" />

        </RelativeLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="14-JUN-2016"
            android:id="@+id/textViewEventTime"
            android:layout_below="@+id/textViewEventStory"
            android:layout_toRightOf="@+id/imageViewEventTimeIcon"
            android:layout_toEndOf="@+id/imageViewEventTimeIcon"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="3dp" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewEventStory"
            android:layout_marginLeft="180dp"
            android:layout_alignEnd="@+id/textViewEventStory"
            android:id="@+id/locationLayout"
            android:layout_alignParentEnd="true"
            android:layout_marginRight="5dp">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Location"
            android:id="@+id/textViewEventLocation"
            android:layout_toRightOf="@+id/imageViewEventLocationIcon" />

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:id="@+id/imageViewEventLocationIcon"
            android:src="@drawable/event_location" />

        </RelativeLayout>

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:id="@+id/imageViewEventTimeIcon"
            android:src="@drawable/event_time"
            android:layout_below="@+id/textViewEventStory"
            android:layout_alignParentLeft="false"
            android:layout_marginLeft="5dp" />

    </RelativeLayout>
</android.support.v7.widget.CardView>

java代码,这里正在给我的布局充气:

    @Override
public RecyclerView.ViewHolder onCreateViewHolderImpl(ViewGroup viewGroup, final ParallaxRecyclerAdapter<Information> adapter, int i) {

    LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
    return new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.custom_row, viewGroup, false));

}

并且最重要的是SDK 23上没有出现这个问题,我不知道其他SDK,但我只在SDK 23和19上测试过它,SDK 19抛出了这个错误。我检查了一些类似于我的问题,我知道内存异常可能导致这种情况,所以我试图不将任何图像分配给我的imageView但仍存在问题

如果有人知道的话,不知道这里有什么问题请告诉我

0 个答案:

没有答案