所以,我想用可点击的国家制作一个可滚动的世界地图。所以当我发现有VectorDrawables
这样的东西时,我决定尝试一下。
我接下来要做的是从VectorDrawable xml
制作一个SVG
文件并尝试将其放入我的ImageView
。在搜索一些信息时,我发现有101种方法可以做到这一点,而且没有一种方法可以帮助我......
有趣的是,当我在"android:src="@raw/worldmap"
的{{1}}中添加ImageView
时,地图会显示在预览中,但每当我尝试运行该应用时,它都会崩溃。< / p>
activity.xml
答案 0 :(得分:1)
首先,将您的VectorDrawable
移至Drawable
文件夹(不是原始文件夹)。然后,在Gradle文件中添加以下行:
defaultConfig{
vectorDrawables.useSupportLibrary = true
}
最后,在您的imageView中,更改为此;
<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:scaleType="center"
app:srcCompat="@drawable/worldmap">
</ImageView>