inflate android.support.v4.widget.CircleImageView inflateException

女生的网名这么多〃 提交于 2020-01-04 02:53:11

问题


I started migrating my app to material design so I changed one of my ImageViews to android.support.v4.widget.CircleImageView and the app crashes the fact is that it can't inflate it but if I use the same as CircleImageView from android v21 on a lollipop device works perfectly with the same attributtes.

so to test it alone I've created a new project with only this View under the layout and still crashes.

<android.support.v4.widget.CircleImageView
                    android:id="@+id/activity_lists_user_profile_picture"
                    android:layout_width="70dp"
                    android:layout_height="70dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="16dp"
                    android:layout_marginTop="38dp"
                    android:src="@drawable/ic_new" />

also I found people with the same problem with a google ticket, but it was marked as spam :(

Does any one knows which are the requirements of CircleImageView support v4 library


回答1:


http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.2_r1/android/support/v4/widget/CircleImageView.java

Says CircleImageView is a private class? Means you can't use it.




回答2:


If you're using Android Studio, you can just Cmd+B (using a Mac) into the class, copy and paste into a new class file and use it straight away. By right there shouldn't be any other custom attributes being used.




回答3:


it's package local, you can create a new class in the same namespace android.support.v4.widget that inherits CircleImageView, perhaps it may not work in future releases of the support library

package android.support.v4.widget;

public class MyCircleImageView extends CircleImageView {
     // constructors
}


来源:https://stackoverflow.com/questions/28616578/inflate-android-support-v4-widget-circleimageview-inflateexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!