How to display static google map on android imageview?

后端 未结 8 1940
长情又很酷
长情又很酷 2020-12-04 06:33

I want to display a static google map on an imageview. Something similar to \"Whatsapp\" showing while share the location. How can I do this?

8条回答
  •  悲哀的现实
    2020-12-04 06:54

    Also, another solution is the Picasso library: "A powerful image downloading and caching library for Android"

    You give an image url to Picasso and then It does a GET petition and it loads the image. If the petition fails then Picasso can set a default image.

    You can even set a progress animation while the image is loading.

    It is a good and clean solution.

    A example:

    ImageView ivUrl = (ImageView) view.findViewById(R.id.iv_photo);
    
    Picasso.with(getContext()).cancelRequest(ivUrl);
    
    Picasso.with(getContext())
        .load(imageUrlString)
        .error(R.drawable.ic_error)
        .placeholder(R.drawable.progress_animation)
        .into(ivUrl);
    

提交回复
热议问题