Mar*_*cGV 11 android android-custom-view android-context android-view android-support-library
Android Studio将此行标记为错误:
public class ParallaxView extends ImageView
Run Code Online (Sandbox Code Playgroud)
这里的错误:
This custom view should extend android.support.v7.widget.AppCompatImageView instead less... (Ctrl+F1)
In order to support features such as tinting, the appcompat library will automatically load special appcompat replacements for the builtin widgets.
However, this does not work for your own custom views. Instead of extending the android.widget classes directly, you should instead extend one of the delegate classes in android.support.v7.widget.AppCompat.
Run Code Online (Sandbox Code Playgroud)
它建议我扩展,AppCompatImageView但我的JUnit测试不会通过,因为AppCompatImageView需要一个模拟Context资源,Imageview不需要这个.
这里是解决其他问题的问题:
NullPointerException使用模拟Context创建AppCompatImageView
我可以忽略此错误并使用ImageView吗?还有其他方法吗?
dev*_*max 19
使用AppCompat小部件可以让您在具有Android前Lollipop版本的设备上拥有一些材料设计(和其他新功能).
此时AppCompatImageView仅提供对背景色调和矢量绘图的支持.如果你不使用它们,那么扩展常规ImageView就可以了.