Android - 将多个图像合并为一个ImageView [英] Android - combine multiple images into one ImageView

查看:1713
本文介绍了Android - 将多个图像合并为一个ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找帮助开发(或库),这可以让我将多个图像合并到一个图像视图中。

I'm looking for help developing (or a library) which can allow me to merge together multiple images into one imageview.

我的应用程序将组合在一起用户,而不是单独显示它们,因此我想合并它们的所有化身,以便一个适配器单元可视化组。

My application is grouping together interactions between users, instead of displaying them singularly, and therefore I would like to merge all of their avatars, so that one adapter cell visualizes a "group".

一个很棒的例子这是在facebook.com的聊天中完成的:

A fantastic example of this is done on facebook.com's chat as such:

我的问题是,如何在Android / Java中提供此功能?据推测,它可能会有1到4之间的图像。请告诉我你能给出的任何建议:)

My question is, how can I provide this functionality in Android / Java? Presumably, it could a number of images between 1 and 4. Please let me know of any advice you can give :)

推荐答案

您可以使用MultiImageView。

You can use MultiImageView.

app.gradle 中添加相关性:

compile 'com.github.stfalcon:multiimageview:0.1'

将MultiImageView添加到布局xml文件

Add MultiImageView to layout xml file

<com.stfalcon.multiimageview.MultiImageView
    android:id="@+id/iv"
    android:layout_width="100dp"
    android:layout_height="100dp"/>

在java类中按id查找视图:

In java class find view by id:

final MultiImageView multiImageView = (MultiImageView) findViewById(R.id.iv);

要将图像添加到MultiImageView,请使用方法addImage(位图位图)。对于exapple:

For adding image to MultiImageView use method addImage(Bitmap bitmap). For exapple:

multiImageView.addImage(BitmapFactory.decodeResource(getResources(), R.drawable.avatar1));

用于设置MultiImageView的形状使用方法setShape(MultiImageView.Shape shape)。

For setting shape of MultiImageView use method setShape(MultiImageView.Shape shape).

multiImageView.setShape(MultiImageView.Shape.RECTANGLE);//Rectangle with round corners
multiImageView.setShape(MultiImageView.Shape.CIRCLE);//Circle
multiImageView.setShape(MultiImageView.Shape.NONE);//Without shape



检查 github 链接获取更多信息:


Check github link for more information:

我认为这是你需要的

这篇关于Android - 将多个图像合并为一个ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆