问题描述
我正在寻找帮助开发(或库),这可以让我将多个图像合并到一个图像视图中。
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!