Android三角标签View:TriangleLabelView

Android三角标签View:TriangleLabelView

在一些商城、产品推销类APP中,如淘宝、京东、电影门票销售、商品降价促销这类的APP,常常会在其APP中看到,某些商品的左上角或者右上角有一些三角的标签,这些标签View的实现很多种,我在以前介绍过一种第三方开源的实现,见附录文章1。
本文再介绍一种类似实现:TriangleLabelView。
TriangleLabelView是第三方开源项目,其在github上的项目主页是:https://github.com/shts/TriangleLabelView 
实现结果如图所示:



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

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     xmlns:tools="http://schemas.android.com/tools"  
  4.     android:layout_width="match_parent"  
  5.     android:layout_height="match_parent"  
  6.     tools:context="zhangphil.demo.MainActivity">  
  7.   
  8.     <RelativeLayout  
  9.         android:layout_width="wrap_content"  
  10.         android:layout_height="wrap_content"  
  11.         android:layout_centerInParent="true">  
  12.   
  13.         <TextView  
  14.             android:layout_width="200dip"  
  15.             android:layout_height="100dip"  
  16.             android:layout_centerInParent="true"  
  17.             android:background="@android:color/holo_blue_light"  
  18.             android:gravity="center"  
  19.             android:text="Zhang Phil" />  
  20.   
  21.         <jp.shts.android.library.TriangleLabelView xmlns:app="http://schemas.android.com/apk/res-auto"  
  22.             android:layout_width="match_parent"  
  23.             android:layout_height="match_parent"  
  24.             android:layout_alignParentLeft="true"  
  25.             android:layout_alignParentTop="true"  
  26.             app:backgroundColor="@android:color/holo_orange_light"  
  27.             app:corner="leftTop"  
  28.             app:labelBottomPadding="5dp"  
  29.             app:labelCenterPadding="0dp"  
  30.             app:labelTopPadding="10dp"  
  31.             app:primaryText="CSDN"  
  32.             app:primaryTextColor="@android:color/holo_red_light"  
  33.             app:primaryTextSize="16sp"  
  34.             app:secondaryText="blog"  
  35.             app:secondaryTextColor="@android:color/holo_purple"  
  36.             app:secondaryTextSize="11sp" />  
  37.   
  38.     </RelativeLayout>  
  39.   
  40. </RelativeLayout>  


代码运行结果如图:


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值