电商、商城类APP常用标签"hot"--第三方开源--LabelView
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的更多相关文章
- nopcommerce 电商商城 ASP.NET 开源系统
nopcommerce 电商商城 ASP.NET 开源系统
- Android音乐、视频类APP常用控件:DraggablePanel(2)
Android音乐.视频类APP常用控件:DraggablePanel(2) 附录文章1主要演示了如何使用DraggablePanel 的DraggableView.DraggablePanel ...
- Android音乐、视频类APP常用控件:DraggablePanel(1)
Android音乐.视频类APP常用控件:DraggablePanel(1) Android的音乐视频类APP开发中,常涉及到用户拖曳视频.音乐播放器产生一定交互响应的设计需求,最典型的以You ...
- iOS开发之资讯类App常用分类控件的封装与实现(CollectionView+Swift3.0+)
今天博客中,我们就来实现一下一些常用资讯类App中常用的分类选择的控件的封装.本篇博客中没有使用到什么新的技术点,如果非得说用到了什么新的技术点的话,那么勉强的说,用到了一些iOS9以后UIColle ...
- 项目内部IT/电商/信息化类简报,分享电子版
除了一些国内不准发的内容,还有公司内部项目相关的.其他的大多数资料会在微信公众号推送,分享一下吧,希望大家也能推荐一些好文章. 微信公众号:WallinWind,原创IT类文章在CSDN博客也会同步更 ...
- 开发者如何快速搭建自己的电商App?
面向电商购物场景,HMS Core提供了创新的电商解决方案,帮助应用快速获客.提升转化率,实现业务增长.为了帮助开发者了解如何在电商购物类应用中集成HMS Core的各项能力,HMS Core开发了电 ...
- iOS开发之常用资讯类App的分类展示与编辑的完整案例实现(Swift版)
上篇博客我们聊了<资讯类App常用分类控件的封装与实现(CollectionView+Swift3.0)>,今天的这篇博客就在上篇博客的基础上做些东西.做一个完整的资讯类App中的分类展示 ...
- 第四章 电商云化,4.2 集团AliDocker化双11总结(作者: 林轩、白慕、潇谦)
4.2 集团AliDocker化双11总结 前言 在基础设施方面,今年双11最大的变化是支撑双11的所有交易核心应用都跑在了Docker容器中.几十万Docker容器撑起了双11交易17.5万笔每秒的 ...
- 电商H5制作常使用的排版方式
在很多电商网站或者APP中,经常会出现一些精美夺目的活动宣传海报,吸引着用户点击.购买.如今,电商们可以把海报搬到微信中,做出面向用户群大.传播快的H5制作.那么,制作电商H5制作时可以使用哪三种排版 ...
随机推荐
- C# 数据回滚
public int GetExecteQuery(string strAddSql, string strUpdateSql, string strDelSql) { SqlConnection c ...
- (medium)LeetCode 264.Ugly Number II
Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...
- ubuntu英文乱码解决
ubuntu英文乱码: vi /etc/default/locale LANG="en_US.UTF-8" LANGUAGE="en_US:en" 配置更 ...
- Eclipse不能进入断点
如题:Eclipse不能进入断点,可能是项目没有build,如果是maven项目,clean,在maven install就可以了
- js中字符串的截取
当需要从一组数据中移除到符合条件的某一个数据的时候,在这种情况下如何进行截取呢? 基本思路: ①将其通过特定的符号,将一组字符串进行拼接,或者用","或者用"+" ...
- Apache FtpServer扩展【动手实现自己的业务】
Apache FtpServer是当下最热门的走ftp协议的用于用户上传下载的服务器. 官网http://mina.apache.org/ftpserver-project/ 一般来说,用的话,去 ...
- C# Exception 对象的属性
关于 C# 中 Exception 对象的属性,在程序出现异常时,需要记录异常的信息,并把信息保存起来或输出,以方便准确定位异常的根源,以下是 Exception 对象的属性 名称 ...
- CODEVS1291 火车线路
http://codevs.cn/problem/1291/ 题目描述 Description 某列火车行使在C个城市之间(出发的城市编号为1,结束达到的城市的编号为C),假设该列火车有S个座位,现在 ...
- java.sql.SQLException: Access denied for user 'root'
程序在连接远程 mysql服务器时出错 java.sql.SQLException: Access denied for user 'root'@'192.168.27.129' (using pas ...
- Bug修复问题
采用下面的代码,访问网页:http://www.weather.com.cn/data/cityinfo/101010100.html,想读取下图中红框中的内容,但是抛出了IOException,通过 ...