How to fit video in Live wallpaper, by center-crop and by fitting to width/height?

后端 未结 5 1279
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 09:42

Background

I\'m making a live wallpaper that can show a video. In the beginning I thought this is going to be very hard, so some people suggested using OpenGL solu

5条回答
  •  离开以前
    2020-12-08 10:11

    You can use Glide for GIF and image loading and its give scaling options as you like. Based on document https://bumptech.github.io/glide/doc/targets.html#sizes-and-dimensions and https://futurestud.io/tutorials/glide-image-resizing-scaling this.

    Glide v4 requires Android Ice Cream Sandwich (API level 14) or higher.

    Like :

    public static void loadCircularImageGlide(String imagePath, ImageView view) {
        Glide.with(view.getContext())
                .load(imagePath)
                .asGif()
                .override(600, 200) // resizes the image to these dimensions (in pixel). resize does not respect aspect ratio
                .error(R.drawable.create_timeline_placeholder)
                .fitCenter() // scaling options
                .transform(new CircularTransformation(view.getContext())) // Even you can Give image tranformation too
                .into(view);
    }
    

提交回复
热议问题