我使用来自https://github.com/pents90/svg-android的svg-android.jar工作正常,但只在eclipse的模拟器设备上使用。农业。在真正的设备上,它只是在屏幕上清空imageView。下面是我的代码:
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.test);
Drawable drawable = svg.createPictureDrawable();
imgView.setImageDrawable(drawable);有什么建议吗?
发布于 2013-08-21 21:24:10
在默认情况下启用硬件渲染的较新设备上,需要显式启用软件渲染。
imgView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);我怀疑这可能是你的问题。
发布于 2017-08-29 14:09:44
在xml中使用AppCompatImageView而不是ImageView,如以下代码所示
<android.support.v7.widget.AppCompatImageView
android:tint="#d74313"
app:srcCompat="@drawable/circle_icon"
android:layout_width="30sp"
android:layout_height="30sp" />在你的build.gradle中
android {
defaultConfig {
vectorDrawables {
useSupportLibrary = true
}
}
}如果上面的方法不起作用,也可以在您的应用程序类中尝试
public class App extends Application {
@Override public void onCreate() {
super.onCreate();
// Make sure we use vector drawables
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}https://stackoverflow.com/questions/18356098
复制相似问题