您的位置:首页 > 移动开发 > Android开发

Android图片添加标签:Android-PictureTagView

2015-11-02 14:32 411 查看

Android图片添加标签:Android-PictureTagView
在一些社交类、美图类的Android APP中,会给用户提供一项功能就是给图片添加一些标签,这种功能需求可以使用一个在githubs上的第三方的开源库Android-PictureTagView。

Android-PictureTagView在github上的项目主页:https://github.com/saiwu-bigkoo/Android-PictureTagView

截止目前,Android-PictureTagView的版本中,比较关键的是PictureTagLayout。此类将加载到PictureTagLayout布局中的ImageView添加一些标签,当点击PictureTagLayout布局中的ImageView时,就自动添加进去一些标签,这些标签支持拖曳移动,但似乎目前不支持添加后删除,如果欲删除这些标签,则需要开发者自己再做二次定制开发,据我初步对源代码的阅读和分析,比如,可以在PictureTagLayout中增加长按事件,长按后弹出对话框然后删除等等动作。

(1) 使用Android-PictureTagView。直接在布局中像普通的线性布局或者相对布局一样使用PictureTagLayout(PictureTagLayout继承自RelativeLayout)。

(2) 在PictureTagLayout中写入一个ImageView。此ImageView将被用户的点击事件触发添加标签动作。

比如,写一个布局文件:

<?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:background="@android:color/white"
android:orientation="vertical" >

<com.picturetagview.PictureTagLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_launcher" />

</LinearLayout>

运行结果如图:



附录一些相关供进一步开发的文章:

《Android View转换成图片保存》链接地址:http://blog.csdn.net/zhangphil/article/details/44217539
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: