Android三角标签View:TriangleLabelView

在一些商城、产品推销类APP中,如淘宝、京东、电影门票销售、商品降价促销这类的APP,常常会在其APP中看到,某些商品的左上角或者右上角有一些三角的标签,这些标签View的实现很多种,我在以前介绍过一种第三方开源的实现,见附录文章1。

本文再介绍一种类似实现:TriangleLabelView。

TriangleLabelView是第三方开源项目,其在github上的项目主页是:https://github.com/shts/TriangleLabelView


实现结果如图所示:

TriangleLabelView可以通过配置xml文件即可实现,我写一个例子说明:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="zhangphil.demo.MainActivity"> <RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"> <TextView
android:layout_width="200dip"
android:layout_height="100dip"
android:layout_centerInParent="true"
android:background="@android:color/holo_blue_light"
android:gravity="center"
android:text="Zhang Phil" /> <jp.shts.android.library.TriangleLabelView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
app:backgroundColor="@android:color/holo_orange_light"
app:corner="leftTop"
app:labelBottomPadding="5dp"
app:labelCenterPadding="0dp"
app:labelTopPadding="10dp"
app:primaryText="CSDN"
app:primaryTextColor="@android:color/holo_red_light"
app:primaryTextSize="16sp"
app:secondaryText="blog"
app:secondaryTextColor="@android:color/holo_purple"
app:secondaryTextSize="11sp" /> </RelativeLayout> </RelativeLayout>

代码运行结果如图:

附录文章:

1,《Android View标签LabelView(电商、商城类APP常用)》链接地址:http://blog.csdn.net/zhangphil/article/details/49836773

Android三角标签View:TriangleLabelView的更多相关文章

  1. Android轶事之View要去大保健?View大小自己决定?

    -"爹,我要吃糖" -"好哒儿子" -"爹,我要吃包包" - "好哒儿子" - "爹,我要吃串串" ...

  2. (转载)Android自定义标签列表控件LabelsView解析

    Android自定义标签列表控件LabelsView解析 作者 donkingliang 关注 2017.03.15 20:59* 字数 759 阅读 406评论 0喜欢 3 无论是在移动端的App, ...

  3. Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect)

    Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect) [TOC] 这两个方法的区别 View.ge ...

  4. 1.Android 视图及View绘制分析笔记之setContentView

    自从1983年第一台图形用户界面的个人电脑问世以来,几乎所有的PC操作系统都支持可视化操作,Android也不例外.对于所有Android Developer来说,我们接触最多的控件就是View.通常 ...

  5. Android读取自定义View属性

    Android读取自定义View属性 attrs.xml : <?xml version="1.0" encoding="utf-8"?> < ...

  6. android中实现view可以滑动的六种方法续篇(二)

    承接上一篇,上一篇中讲解了实现滑动的第五种方法,如果你还没读过,可点击下面链接: http://www.cnblogs.com/fuly550871915/p/4985482.html 这篇文章现在来 ...

  7. Android点击View显示PopupWindow,再次重复点击View关闭PopupWindow

     Android点击View显示PopupWindow,再次重复点击View关闭PopupWindow 这本身是一个看似很简单的问题,但是如果设置不当,就可能导致莫名其妙失效问题.通常在Andro ...

  8. Android Touch(3)View的touchDelegate

    作用: 基类View有个函数 public void setTouchDelegate(TouchDelegate delegate),给view内部的另一个view设置一个touch代理. 图中vi ...

  9. Android 自己定义View (二) 进阶

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24300125 继续自己定义View之旅.前面已经介绍过一个自己定义View的基础 ...

随机推荐

  1. 解决Error for wireless request "Set Mode" (8B06) 问题 (转载)

    转自:http://blog.csdn.net/muge0913/article/details/17062871 在运行以下命令的时候,意外的出错,最后google了下,最终才确定了原因,因为在运行 ...

  2. RT-Thread 设备驱动-硬件定时器浅析与使用

    RT-Thread 4.0.0 访问硬件定时器设备 应用程序通过 RT-Thread 提供的 I/O 设备管理接口来访问硬件定时器设备,相关接口如下所示: 函数 描述 rt_device_find() ...

  3. 汇编程序52:实验15 安装新的int9中断例程

    assume cs:code ;重写int9中断例程,当按住a后松开,便会产生满屏A stack segment dw dup() stack ends code segment start: mov ...

  4. Linux上安装wine qq的方法

    linxu上安装QQ的发 百度网盘 提取码:f2sn 步骤一.安装wine(详见:https://www.winehq.org/download) // ubuntu/ubuntukylin/mint ...

  5. js复制功能

    // 复制功能 copyUrl() { var Url = document.getElementById('biao') Url.select() // 选择对象 document.execComm ...

  6. encodeURIComponent的用法

    实践出真知,项目中遇到坑,填满后总结:编码不一定需要解码 rsa加密字段(base64位后),通过url?filed=value传输后,总是有+等特殊字符,然后到后端时base64解不开,发现很多空格 ...

  7. [书目20140824]触动人心:设计优秀的iPhone应用

    关于作者致谢译者序入门设计令人欣喜且易用的应用等下……先吸口气阅读本书不需要专业知识忠言一切从点击开始       我们是如何使用iPhone应用的行走中:一只手,一只眼睛,一直在抖动尽快搞定满满一箱 ...

  8. struct结构的一些内容

    srtuct结构的定义: 访问修饰符 struct  结构名{ //方法体 } 结构定义的特点: 1.结构中可以有字段(属性),也可以有方法 2.定义时,结构的字段不能被赋初值 3.结构和类一样都有默 ...

  9. 继续C#开发or转做产品

    本人今年大四,C#开发,在一家公司实习了一年后,面临一个选择,是继续C#开发还是转做产品?我C#开发能力目前还一般,但很有兴趣.也喜欢设计与创意,做过产品专员.求大婶们指导!

  10. 处理sql锁死问题

    --SQL Server死锁的查询方法:   exec master.dbo.p_lockinfo 0,0; ---显示死锁的进程,不显示正常的进程   exec master.dbo.p_locki ...