如何为 Android 的苹果手机照片添加标签签

我想要走过很多地方,看不同的城镇村庄,或许还能帮一帮那些遇上困难的人。...
Android 在图片的指定位置添加标记
这些天,项目里加了一个功能效果,场景是: 假如有一个家居图片,图片里,有各样的家居用品: 桌子,毛巾,花瓶等等,需要在指定的商品处添加标记,方便用户直接看到商品,点击该标记,可以进入到商品详情页 。实现的效果图如下:
要实现如上效果,有两个思路。
思路1,通过addView,在容器(如FrameLayout)的特定位置,添加标记组件,同事在将ImageView页添加进容器中,保证容器的大小和ImageView的大小相同,这样可以确认标记点的位置不会出现错差。
思路2,通过绘制Bitmap,将背景图片和标记点绘制成同一张图片。
比较两种方法,思路2有些不太妥的地方,1是不好实现标记图标的点击事件;2是不太容易扩展,比如标记点不仅仅是一个图片,而是一个弹框组件,有图有文。 所以,考虑再三后,决定选择第一种实现方式。
1. 自定义布局,包含放置标记图标的容器及显示底部图片的ImageView。
&?xml version="1.0" encoding="utf-8"?&
&FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"&
&ImageView
android:id="@+id/imgBg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:maxHeight="1000dp"
android:scaleType="centerCrop" /&
&FrameLayout
android:id="@+id/layouPoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" /&
&/FrameLayout&
2. 自定义组件,便于添加标记图标、加载背景图
import android.content.C
import android.graphics.drawable.AnimationD
import android.util.AttributeS
import android.view.LayoutI
import android.view.V
import android.view.ViewG
import android.widget.FrameL
import android.widget.ImageV
import android.widget.LinearL
import android.widget.T
import com.bumptech.glide.G
import com.lnyp.imgdots.R;
import com.lnyp.imgdots.bean.PointS
import java.util.ArrayL
public class ImageLayout extends FrameLayout implements View.OnClickListener {
ArrayList&PointSimple&
FrameLayout layouP
ImageView imgBg;
Context mC
public ImageLayout(Context context) {
this(context, null);
public ImageLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
public ImageLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context, attrs);
private void initView(Context context, AttributeSet attrs) {
mContext =
View imgPointLayout = inflate(context, R.layout.layout_imgview_point, this);
imgBg = (ImageView) imgPointLayout.findViewById(R.id.imgBg);
layouPoints = (FrameLayout) imgPointLayout.findViewById(R.id.layouPoints);
public void setImgBg(int width, int height, String imgUrl) {
ViewGroup.LayoutParams lp = imgBg.getLayoutParams();
lp.width =
lp.height =
imgBg.setLayoutParams(lp);
ViewGroup.LayoutParams lp1 = layouPoints.getLayoutParams();
lp1.width =
lp1.height =
layouPoints.setLayoutParams(lp1);
Glide.with(mContext).load(imgUrl).asBitmap().into(imgBg);
addPoints(width, height);
public void setPoints(ArrayList&PointSimple& points) {
this.points =
private void addPoints(int width, int height) {
layouPoints.removeAllViews();
for (int i = 0; i & points.size(); i++) {
double width_scale = points.get(i).width_
double height_scale = points.get(i).height_
LinearLayout view = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.layout_img_point, this, false);
ImageView imageView = (ImageView) view.findViewById(R.id.imgPoint);
imageView.setTag(i);
AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
animationDrawable.start();
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
layoutParams.leftMargin = (int) (width * width_scale);
layoutParams.topMargin = (int) (height * height_scale);
imageView.setOnClickListener(this);
layouPoints.addView(view, layoutParams);
public void onClick(View view) {
int pos = (int) view.getTag();
Toast.makeText(getContext(), "pos : " + pos, Toast.LENGTH_SHORT).show();
来看看ImageLayout源码,里面有两个重要的方法:
·public void setImgBg(int width, int height, String imgUrl) 该方法主要根据图片的大小,设置标记图容器的大小,然后加载背景图。
·private void addPoints(int width, int height)
该方法主要向记图容器中添加标记图。
3.PointSimple.java
public class PointSimple {
// 标记点相对于横向的宽度的比例
public double width_
// 标记点相对于横向的高度的比例
public double height_
4. 添加背景图和标记图
4.1 首先,准备一些测试数据
private void initData() {
imgSimples = new ArrayList&&();
ImgSimple imgSimple1 = new ImgSimple();
imgSimple1.url = "http://o79w6dswy.bkt.clouddn.com/img5.png";
imgSimple1.scale = 1.6f;
ArrayList&PointSimple& pointSimples = new ArrayList&&();
PointSimple pointSimple1 = new PointSimple();
pointSimple1.width_scale = 0.36f;
pointSimple1.height_scale = 0.75f;
PointSimple pointSimple2 = new PointSimple();
pointSimple2.width_scale = 0.64f;
pointSimple2.height_scale = 0.5f;
PointSimple pointSimple3 = new PointSimple();
pointSimple3.width_scale = 0.276f;
pointSimple3.height_scale = 0.764f;
PointSimple pointSimple4 = new PointSimple();
pointSimple4.width_scale = 0.638f;
pointSimple4.height_scale = 0.74f;
PointSimple pointSimple5 = new PointSimple();
pointSimple5.width_scale = 0.796f;
pointSimple5.height_scale = 0.526f;
PointSimple pointSimple6 = new PointSimple();
pointSimple6.width_scale = 0.486f;
pointSimple6.height_scale = 0.364f;
pointSimples.add(pointSimple1);
pointSimples.add(pointSimple2);
pointSimples.add(pointSimple3);
pointSimples.add(pointSimple4);
pointSimples.add(pointSimple5);
pointSimples.add(pointSimple6);
imgSimple1.pointSimples = pointS
ImgSimple imgSimple2 = new ImgSimple();
imgSimple2.url = "http://o79w6dswy.bkt.clouddn.com/img3.png";
imgSimple2.scale = 1.6f;
ArrayList&PointSimple& pointSimples2 = new ArrayList&&();
PointSimple pointSimple7 = new PointSimple();
pointSimple7.width_scale = 0.36f;
pointSimple7.height_scale = 0.75f;
PointSimple pointSimple8 = new PointSimple();
pointSimple8.width_scale = 0.64f;
pointSimple8.height_scale = 0.5f;
PointSimple pointSimple9 = new PointSimple();
pointSimple9.width_scale = 0.276f;
pointSimple9.height_scale = 0.764f;
pointSimples2.add(pointSimple7);
pointSimples2.add(pointSimple8);
pointSimples2.add(pointSimple9);
imgSimple2.pointSimples = pointSimples2;
ImgSimple imgSimple3 = new ImgSimple();
imgSimple3.url = "http://o79w6dswy.bkt.clouddn.com/421428.jpg";
imgSimple3.scale = 0.75f;
ArrayList&PointSimple& pointSimples3 = new ArrayList&&();
PointSimple pointSimple11 = new PointSimple();
pointSimple11.width_scale = 0.1f;
pointSimple11.height_scale = 0.3f;
PointSimple pointSimple12 = new PointSimple();
pointSimple12.width_scale = 0.3f;
pointSimple12.height_scale = 0.5f;
PointSimple pointSimple13 = new PointSimple();
pointSimple13.width_scale = 0.5f;
pointSimple13.height_scale = 0.8f;
pointSimples3.add(pointSimple11);
pointSimples3.add(pointSimple12);
pointSimples3.add(pointSimple13);
imgSimple3.pointSimples = pointSimples3;
imgSimples.add(imgSimple1);
imgSimples.add(imgSimple2);
imgSimples.add(imgSimple3);
} 4.2 加载图片和添加标记物,因为要做可以滑动展示的效果,所以在ViewPager的PagerAdapter中进行功能添加。
import android.app.A
import android.support.v4.view.PagerA
import android.support.v4.view.ViewP
import android.util.DisplayM
import android.view.LayoutI
import android.view.V
import android.view.ViewG
import android.widget.LinearL
import com.lnyp.imgdots.R;
import com.lnyp.imgdots.bean.ImgS
import com.lnyp.imgdots.bean.PointS
import com.lnyp.imgdots.view.ImageL
import java.util.ArrayL
import java.util.L
public class ImgBrowsePagerAdapter extends PagerAdapter {
List&ImgSimple& imgS
List&View&
Activity mC
public ImgBrowsePagerAdapter(Activity context, List&ImgSimple& imgSimples) {
this.mContext =
this.imgSimples = imgS
this.views = new ArrayList&&();
DisplayMetrics dm = new DisplayMetrics();
context.getWindowManager().getDefaultDisplay().getMetrics(dm);
width = dm.widthP
public int getCount() { // 获得size
return imgSimples.size();
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView((View) object);
public Object instantiateItem(ViewGroup container, int position) {
LinearLayout view = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.layout_img_browse, null);
ImageLayout layoutContent = (ImageLayout) view.findViewById(R.id.layoutContent);
String imgUrl = imgSimples.get(position).
float scale = imgSimples.get(position).
ArrayList&PointSimple& pointSimples = imgSimples.get(position).pointS
layoutContent.setPoints(pointSimples);
int height = (int) (width * scale);
layoutContent.setImgBg(width, height, imgUrl);
} catch (Exception e) {
e.printStackTrace();
((ViewPager) container).addView(view);
4.3 适配器的布局文件layout_img_browse.xml,其中包含了上方自定义的组件ImageLayout
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"&
&com.lnyp.imgdots.view.ImageLayout
android:id="@+id/layoutContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" /&
&/LinearLayout&
此处,稍微讲下ImgBrowsePagerAdapter的instantiateItem(ViewGroup container, int position)方法,在该方法中,我们根据屏幕的宽度,对图片进行等比缩放,计算出了缩放后图片的大小(height和width), 该height和width也就是我们将要添加标记物所在的容器的大小。
通过加载了布局文件,获取ImageLayout对象; 然后,有了这个对象,及计算出的height和width,我们就可以动态的添加背景图及标记物的位置。
因为图片是经过等比缩放的,而标记物的位置是相对于图片的,所以在相同大小的容器添加标记物,它的位置不会出现偏差。
通过以上几步,便可以实现前面动态图中的功能效果了。
如有疑问或建议,欢迎进QQ群讨论:( Android研发村 )
项目github地址:
没有更多推荐了,您好, []|
给照片打上标签 Android软件Labelbox
能被消费者如此追捧,最大的原因不是硬件多么强大,而是背后数十万的应用软件和游戏,好在随着安卓用户的日益壮大越来越多的经典软件都推出了安卓移植版,今天小编就为大家介绍其中的佼佼者—Labelbox,一款优秀的照片管理软件。操作说明打开Labelbox软件,在软件首页提供了操作指南,帮助用户了解如何使用软件,但是遗憾的是没有翻译成中文界面,小编拙劣的帮大家翻译了一下,有错误之处请多包涵,如图所示:从左到右,从上到下依次为第一个照张相或从相册中获取;第二个取消;第三个刷出标签,第四个是晃手机清理全部;第五个是保存并分享;第六个是浏览steply社交平台。 ▲Labelbox操作说面界面用户在使用时,会发现点击图标后并没有改变,这是因为软件隐藏了功能导航栏,要通过点击屏幕下方的“小三角”才能召唤出功能导航栏,细心的朋友也会在图中看到注释“Tap here to start”文字提示。 ▲Labelbox操作说面界面打开隐藏的功能导航栏后,可以看到五颜六色的标签,通过滑动屏幕还可浏览到更多颜色样子的标签内容。 ▲Labelbox标签功能界面
推荐微博:
[责任编辑:raymin]
(请登录发言,并遵守)
如果你对数码频道有任何意见或建议,请到交流平台反馈。【】
新闻排行财经科普科技数码
Copyright & 1998 - 2018 Tencent. All Rights Reserved手机QQ发说说可以添加标签吗?手机QQ发说说怎么添加标签?[多图] - 友情手机站
手机软件手软合集合集排行
您的位置:&>& >
> 手机QQ发说说可以添加标签吗?手机QQ发说说怎么添加标签?
手机QQ发说说可以添加标签吗?手机QQ发说说怎么添加标签?[多图]
字体大小:【 |
11:30:20&&&本站原创
类型:社交网络大小:46.17MB评分:9.8平台:标签:
V7.0版发表说说可以直接添加标签了哦,怎么添加呢,友情小编为大家整理了这篇,关于手机QQ添加标签的方法介绍,分享给大家,希望对大家使用手机QQ有所帮助噢!
手机QQ发说说可以添加标签吗?手机QQ发说说怎么添加标签?
1.打开发说说界面,点击下方添加标签;
2.编辑标签名称,点击完成即可;
3.这样就可以发表标签说说了哦~
以上就是友情小编提供的手机QQ使用教程相关内容,更多,请百度“手机QQ友情手机站”!
专题类型:厂商更新时间:专题标签:腾讯聊天交友社交神器附近的人手机qq是大家再熟悉不过的一款聊天工具了,现在几乎是人手必备的一款app,现在小编是为大家汇总了一下,把以前的一些历史版本都为大...5.0友情指数0人0人
猜你喜欢腾讯聊天交友社交神器附近的人
腾讯集团到底有多大,相信你并不不清楚,但是它却真真实实的生活在我们的周围,而我们可能时时刻刻都在使用着它的产品。想要了解更多产品的朋友们,小编现在就为您带来腾讯...10专区9.4特权10专区10专区特权10专区特权101010专区1010专区9.9专区9.810专区10专区9.810专区特权9.89.910专区9.9专区9.810专区109.3
相关软件其他版本
手机QQ软件资讯1719-199-159-139-119-119-9手机QQ软件教程589-188-198-178-177-256-6手机QQ常见问题1506-612-129-299-97-156-27
(您的评论需要经过审核才能显示)标签:手机图片处理,手机图片处理软件,安卓手机图片处理软件-APK3安卓网
热门搜索:
当前位置:
手机图片处理
【手机图片处理】栏目为您提供手机图片处理、手机图片处理软件、安卓手机图片处理软件、手机图片处理软件有哪些等安卓软件工具!机图片处理软件喜欢自拍的美女们必不可少的一款软件。软件不需要任何美术基础和照片处理基础,只需简单的几步就能让你如同专业模特般漂亮。
手机图片处理大全
简体中文 / 36.6 MB
简体中文 / 36.6 MB
简体中文 / 36.6 MB
简体中文 / 36.6 MB
简体中文 / 36.6 MB
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 17.7M
简体中文 / 37.3M
简体中文 / 37.3M
简体中文 / 37.3M
简体中文 / 40.1M
简体中文 / 40.1M
简体中文 / 40.1M
简体中文 / 40.1M
简体中文 / 40.1M
简体中文 / 31.17MB
简体中文 / 31.17MB
手机图片处理相关文章}

我要回帖

更多关于 苹果手机照片添加标签 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信