LabelView是在github上一个开源的标签库。其项目主页是:https://github.com/linger1216//labelview 
LabelView为一个TextView,ImageView或者为ListView中适配器getView返回的View,增加一个左上角或者右上角的标签

这种需求设计在商城类APP、电商类APP中比较常用,这些APP展示的商品,通常会增加一些促销或者该类商品的特征。
LabelView集成自Android TextView,可以像使用Android TextView一样使用LabelView,LabelView使用简单,如代码所示:

布局代码:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.zzw.textlabelview.MainActivity" > <TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#90CAF9"
android:gravity="center"
android:text="textView1"
android:textSize="30sp" /> <TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#9FA8DA"
android:gravity="center"
android:text="textView2"
android:textSize="30sp" /> <ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" /> <ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#B39DDB"
android:src="@drawable/ic_launcher" /> <View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="100dip"
android:background="#e0e0e0" >
</View> </LinearLayout>

JAVA代码:

 package com.zzw.textlabelview;

 import com.lid.lib.LabelView;
import com.lid.lib.LabelView.Gravity; import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //为TextView1左上角添加一个标签
LabelView label1 = new LabelView(this);
label1.setText("Hot");
label1.setBackgroundColor(0xff03a9f4);
label1.setTargetView(findViewById(R.id.textView1), 4, Gravity.LEFT_TOP); //为TextView2右上角添加一个标签,点击标签移除
final LabelView label2 = new LabelView(this);
label2.setText("点击移除");
label2.setBackgroundColor(0xffE91E63);
label2.setTargetView(findViewById(R.id.textView2), 20,
Gravity.RIGHT_TOP);
findViewById(R.id.textView2).setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
label2.remove();
Toast.makeText(getApplicationContext(), "标签移除成功", 0).show();
}
}); //为ImageView1添加一个左上角标签,并且自定义标签字颜色
LabelView label3 = new LabelView(this);
label3.setText("推荐");
label3.setTextColor(Color.RED);
label3.setBackgroundColor(0xff03a9f4);
label3.setTargetView(findViewById(R.id.imageView1), 10,
Gravity.LEFT_TOP); //为IamgeView2添加一个右上角标签
LabelView label4 = new LabelView(this);
label4.setText("推荐");
label4.setBackgroundColor(0xffE91E63);
label4.setTargetView(findViewById(R.id.imageView2), 10,
Gravity.RIGHT_TOP); //为一个View添加一个左上角标签(ListView用)
LabelView label5 = new LabelView(this);
label5.setText("view");
label5.setTextColor(Color.BLUE);
label5.setBackgroundColor(0xffE91E63);
label5.setTargetView(findViewById(R.id.view), 10, Gravity.LEFT_TOP);
}
}

电商、商城类APP常用标签"hot"--第三方开源--LabelView的更多相关文章

  1. nopcommerce 电商商城 ASP.NET 开源系统

    nopcommerce 电商商城 ASP.NET 开源系统

  2. Android音乐、视频类APP常用控件:DraggablePanel(2)

     Android音乐.视频类APP常用控件:DraggablePanel(2) 附录文章1主要演示了如何使用DraggablePanel 的DraggableView.DraggablePanel ...

  3. Android音乐、视频类APP常用控件:DraggablePanel(1)

     Android音乐.视频类APP常用控件:DraggablePanel(1) Android的音乐视频类APP开发中,常涉及到用户拖曳视频.音乐播放器产生一定交互响应的设计需求,最典型的以You ...

  4. iOS开发之资讯类App常用分类控件的封装与实现(CollectionView+Swift3.0+)

    今天博客中,我们就来实现一下一些常用资讯类App中常用的分类选择的控件的封装.本篇博客中没有使用到什么新的技术点,如果非得说用到了什么新的技术点的话,那么勉强的说,用到了一些iOS9以后UIColle ...

  5. 项目内部IT/电商/信息化类简报,分享电子版

    除了一些国内不准发的内容,还有公司内部项目相关的.其他的大多数资料会在微信公众号推送,分享一下吧,希望大家也能推荐一些好文章. 微信公众号:WallinWind,原创IT类文章在CSDN博客也会同步更 ...

  6. 开发者如何快速搭建自己的电商App?

    面向电商购物场景,HMS Core提供了创新的电商解决方案,帮助应用快速获客.提升转化率,实现业务增长.为了帮助开发者了解如何在电商购物类应用中集成HMS Core的各项能力,HMS Core开发了电 ...

  7. iOS开发之常用资讯类App的分类展示与编辑的完整案例实现(Swift版)

    上篇博客我们聊了<资讯类App常用分类控件的封装与实现(CollectionView+Swift3.0)>,今天的这篇博客就在上篇博客的基础上做些东西.做一个完整的资讯类App中的分类展示 ...

  8. 第四章 电商云化,4.2 集团AliDocker化双11总结(作者: 林轩、白慕、潇谦)

    4.2 集团AliDocker化双11总结 前言 在基础设施方面,今年双11最大的变化是支撑双11的所有交易核心应用都跑在了Docker容器中.几十万Docker容器撑起了双11交易17.5万笔每秒的 ...

  9. 电商H5制作常使用的排版方式

    在很多电商网站或者APP中,经常会出现一些精美夺目的活动宣传海报,吸引着用户点击.购买.如今,电商们可以把海报搬到微信中,做出面向用户群大.传播快的H5制作.那么,制作电商H5制作时可以使用哪三种排版 ...

随机推荐

  1. linux下udp编程

    #include<sys/types.h> #include<sys/socket.h> #include<unistd.h> #include<netine ...

  2. (收藏)C#实现截屏

    项目中使用winform截图,下面两篇文章不错的,能够直接使用. http://www.cnblogs.com/xugang/archive/2007/12/19/1006066.html http: ...

  3. JQuery基础教程:选择元素(下)

    DOM遍历方法   利用前面介绍的jQuery选择符取得一组元素,就像是我们在DOM树中纵横遍历再经过筛选得到的结果一样.如果只有这一种取得元素的方式,那我们选择的余地从某个角度讲也是很有限的.很多情 ...

  4. VC ClistCtrl不同行背景色

    大家经常用到listctrl 做表格 为了好看,要给每行设置不同背景色.很实用的一个小技巧. 1:首先在.h里添加以下消息 afx_msg void OnDrawColorForMyList(NMHD ...

  5. 断言--NSAssert

    NSAssert()是一个宏,用于开发阶段调试程序中的Bug,通过为NSAssert()传递条件表达式来断定是否属于Bug,满足条件返回真值,程序继续运行,如果返回假值,则抛出异常,并切可以自定义异常 ...

  6. socket学习笔记——select与epoll函数的使用(linux)

    select.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <u ...

  7. Vmware ESX5i 环境下部署Windows Storage Server 2008 R2

    ESX5i 环境下部署Windows Storage Server 2008 R2       Windows Storage Server 2008 这款产品微软早已发布,WSS2008是基于Win ...

  8. 【Hibernate 9】悲观锁和乐观锁

    一.锁的基本简介 1.1,为什么需要锁 首先,锁的概念产生,主要是为了解决并发性的问题.什么是并发性问题呢,比如: Angel现在银行有个账号,里面有存款1000块.现在,Angel的账户,在两个地方 ...

  9. ios delegate 代理模式 观察者模式 不同视图间的通信

    delegate,在ios中比比皆是,NSURLConnection(网络请求有),tableView, connectionView,等系统自带 的常见代理.甚至,自己写代码的时候,随意间敲打出了p ...

  10. 【Linux】Centos部署MySQL

    将CentOS部署MySQL需要本地配置环境.本地编译MySQL,耗时较长的情况,优化为编译成型MySQL并打包,推送并按配置部署. 首先需要在一台机器配置好环境,搭个YUM源,并将所需要的包取出备用 ...