-
大小: 4KB文件類型: .rar金幣: 2下載: 0 次發布日期: 2021-05-16
- 語言: 其他
- 標簽: flowtaglayou??
資源簡介
flowtaglayout相關源碼 直接copy到項目中即可使用。。。。。。。。。。。

代碼片段和文件信息
package?com.xj.hpqq.huopinquanqiu.widget.flowtaglayout;
import?android.content.Context;
import?android.database.DataSetObserver;
import?android.util.AttributeSet;
import?android.util.SparseBooleanArray;
import?android.view.View;
import?android.view.ViewGroup;
import?android.widget.ListAdapter;
import?java.util.ArrayList;
import?java.util.Arrays;
import?java.util.List;
/**
?*?流式標簽布局
?*?原理:重寫{@link?ViewGroup#onMeasure(int?int)}
?*?和{@link?ViewGroup#onLayout(boolean?int?int?int?int)}
?*?方法
?*?Created?by?HanHailong?on?15/10/19.
?*/
public?class?FlowTagLayout?extends?ViewGroup?{
????private?static?final?String?TAG?=?FlowTagLayout.class.getSimpleName();
????/**
?????*?FlowLayout?not?support?checked
?????*/
????public?static?final?int?FLOW_TAG_CHECKED_NONE?=?0;
????/**
?????*?FlowLayout?support?single-select
?????*/
????public?static?final?int?FLOW_TAG_CHECKED_SINGLE?=?1;
????/**
?????*?FlowLayout?support?multi-select
?????*/
????public?static?final?int?FLOW_TAG_CHECKED_MULTI?=?2;
????/**
?????*?Should?be?used?by?subclasses?to?listen?to?changes?in?the?dataset
?????*/
????AdapterDataSetObserver?mDataSetObserver;
????/**
?????*?The?adapter?containing?the?data?to?be?displayed?by?this?view
?????*/
????ListAdapter?mAdapter;
????/**
?????*?the?tag?click?event?callback
?????*/
????OnTagClickListener?mOnTagClickListener;
????/**
?????*?the?tag?select?event?callback
?????*/
????OnTagSelectListener?mOnTagSelectListener;
????/**
?????*?標簽流式布局選中模式,默認是不支持選中的
?????*/
????private?int?mTagCheckMode?=?FLOW_TAG_CHECKED_NONE;
????/**
?????*?存儲選中的tag
?????*/
????private?SparseBooleanArray?mCheckedTagArray?=?new?SparseBooleanArray();
????public?FlowTagLayout(Context?context)?{
????????super(context);
????}
????public?FlowTagLayout(Context?context?AttributeSet?attrs)?{
????????super(context?attrs);
????}
????public?FlowTagLayout(Context?context?AttributeSet?attrs?int?defstyleAttr)?{
????????super(context?attrs?defstyleAttr);
????}
????@Override
????protected?void?onMeasure(int?widthMeasureSpec?int?heightMeasureSpec)?{
????????super.onMeasure(widthMeasureSpec?heightMeasureSpec);
????????//獲取Padding
????????//?獲得它的父容器為它設置的測量模式和大小
????????int?sizeWidth?=?MeasureSpec.getSize(widthMeasureSpec);
????????int?sizeHeight?=?MeasureSpec.getSize(heightMeasureSpec);
????????int?modeWidth?=?MeasureSpec.getMode(widthMeasureSpec);
????????int?modeHeight?=?MeasureSpec.getMode(heightMeasureSpec);
????????//FlowLayout最終的寬度和高度值
????????int?resultWidth?=?0;
????????int?resultHeight?=?0;
????????//測量時每一行的寬度
????????int?lineWidth?=?0;
????????//測量時每一行的高度,加起來就是FlowLayout的高度
????????int?lineHeight?=?0;
????????//遍歷每個子元素
????????for?(int?i?=?0?childCount?=?getChildCount();?i?????????????View?childView?=?getChildAt(i);
????????????//測量每一個子view的寬和高
????????????measureChild(childView?widthMeasureSpec?heightMeasureSpec);
????????????//獲取到測量的寬和高
????????????int?childWidth?=?childView.getMeasuredWidth();
????????????int?childHeight?=?childView.getMea
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????12194??2017-12-29?17:00??flowtaglayout\FlowTagLayout.java
?????文件????????193??2017-12-28?13:26??flowtaglayout\OnInitSelectedPosition.java
?????文件????????239??2017-12-28?13:26??flowtaglayout\OnTagClickListener.java
?????文件????????241??2017-12-28?13:26??flowtaglayout\OnTagSelectListener.java
?????目錄??????????0??2018-06-13?14:28??flowtaglayout
-----------?---------??----------?-----??----
????????????????12867????????????????????5
- 上一篇:基于QT的網絡聊天室+收發數據及文件+源代碼
- 下一篇:習語言安裝使用教程.pdf
評論
共有 條評論