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. va_start和va_end使用详解(转载)

    转自:http://www.cnblogs.com/hanyonglu/archive/2011/05/07/2039916.html 本文主要介绍va_start和va_end的使用及原理. 在以前 ...

  2. bzoj 1999: [Noip2007]Core树网的核【树的直径+单调队列】

    我要懒死了,所以依然是lyd的课件截图 注意是min{max(max(d[uk]),dis(u1,ui),dis(uj,un))},每次都从这三个的max里取min #include<iostr ...

  3. 洛谷 P1582 倒水

    题目描述 一天,CC买了N个容量可以认为是无限大的瓶子,开始时每个瓶子里有1升水.接着~~CC发现瓶子实在太多了,于是他决定保留不超过K个瓶子.每次他选择两个当前含水量相同的瓶子,把一个瓶子的水全部倒 ...

  4. 实数类型c++

    数据类型 定义标识符 数值范围 占字节数 有效位数 单精度浮点数 float -3.4E+38-3.4E+38 4(32位) 6-7位 双精度浮点数 double -1.7E+308-1.7E+308 ...

  5. [BZOJ5109/CodePlus2017]大吉大利,晚上吃鸡!

    Description 最近<绝地求生:大逃杀>风靡全球,皮皮和毛毛也迷上了这款游戏,他们经常组队玩这款游戏.在游戏中,皮皮和毛毛最喜欢做的事情就是堵桥,每每有一个好时机都能收到不少的快递 ...

  6. 锚点、target="page1"、浮标回到顶部(该点未实现,能力不足)

    <html> <head> <meta charset="utf-8"> <title>链接</title> <! ...

  7. js复制功能

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

  8. [译]curl_multi_perform

    http://curl.haxx.se/libcurl/c/curl_multi_perform.html curl_multi_perform.3 -- man page NAMEcurl_mult ...

  9. ubuntu下编译VLC源码

    http://blog.csdn.net/beitiandijun/article/details/9225591ubuntu下编译VLC源码 分类: 视频处理 2013-07-02 17:33 57 ...

  10. django-registration (1048, “Column 'last_login' cannot be null”)

    Go to your database (MySQL Terminal): $ mysql mysql> SELECT * FROM django_migrations; If you see ...