Android三角标签View:TriangleLabelView

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


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

相关文章
|
3月前
|
Android开发 容器
Android UI设计: 什么是View和ViewGroup?
Android UI设计: 什么是View和ViewGroup?
36 0
|
4月前
|
XML API Android开发
Android 自定义View 之 圆环进度条
Android 自定义View 之 圆环进度条
|
6月前
|
SQL 人工智能 移动开发
Android 遍历界面所有的View
本文讲述如何遍历获取页面中所有的view,并输出对应的id,textview文本内容,imageview实际大小及设置的图片大小。 可用于检测android应用中的大图。
|
4月前
|
XML API Android开发
Android 自定义View 之 Dialog弹窗
Android 自定义View 之 Dialog弹窗
|
4月前
|
XML API Android开发
Android 自定义View 之 饼状进度条
Android 自定义View 之 饼状进度条
|
4月前
|
XML API Android开发
Android 自定义View 之 简易输入框
Android 自定义View 之 简易输入框
|
4月前
|
XML API Android开发
Android 自定义View 之 计时文字
Android 自定义View 之 计时文字
|
4月前
|
XML Android开发 数据格式
Android 自定义View 之 Mac地址输入框(下)
Android 自定义View 之 Mac地址输入框(下)
|
4月前
|
XML Java Android开发
Android 自定义View 之 Mac地址输入框(上)
Android 自定义View 之 Mac地址输入框(上)
|
8月前
|
Android开发
Android自定义View 水波气泡2
Android自定义View 水波气泡