Android Tag標籤自定義,TagListView封裝

感謝前輩基礎,特此整理封裝,先來張效果圖吧。


一、tag_bg.xml 默認風格配置

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/tag_checked_pressed"/>
</selector>

二、tag_checked_normal.xml 未選中效果,本示例未啓用

<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="10dp" />
    <solid android:color="@color/white" />
    <stroke android:width="0.5dip" android:color="@color/gray" />
</shape>

三、tag_checked_pressed.xml 選中效果

<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="35dp" />
    <solid android:color="@color/colorAccent" />
    <stroke android:width="0dip" android:color="#ff00aeff" />
</shape>

四、tag.xml控件背景效果等,自己修改想要的效果

<?xml version="1.0" encoding="utf-8"?>
<view.tagview.TagView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawablePadding="5dp"

    android:minHeight="0dp"
    android:paddingBottom="4dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="4.5dp"
    android:textColor="#FFFFFF"
    android:textSize="16sp" />
<!--  android:drawableRight="@drawable/ic_clear_black_24dp"-->

五、attrs.xml

<resources>
<declare-styleable name="FlowLayout"> <attr name="horizontalSpacing" format="dimension"/> <attr name="verticalSpacing" format="dimension"/> <attr name="orientation" format="enum"> <enum name="horizontal" value="0"/> <enum name="vertical" value="1"/> </attr> <attr name="debugDraw" format="boolean" /> </declare-styleable> <declare-styleable name="FlowLayout_LayoutParams"> <attr name="layout_newLine" format="boolean"/> <attr name="layout_horizontalSpacing" format="dimension"/> <attr name="layout_verticalSpacing" format="dimension"/> </declare-styleable></resources>


五、JAVA代碼



源碼下載地址:http://download.csdn.net/detail/tongzhenggang/9796440


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章