流式布局我推荐使用鸿洋大神
https://github.com/hongyangAndroid/FlowLayout
使用
1.在布局中放置流式布局控件
<com.dejun.passionet.commonsdk.widget.flowlayout.TagFlowLayout android:id="@+id/circle_conversation_tfl" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/circle_dp_10" app:max_select="3" />//最大选择个数 2.使用
//流式布局配置 mCircleTfl = (TagFlowLayout) findViewById(R.id.circle_conversation_tfl); mCircleTfl.setAdapter(new TagAdapter<SelectTopicRes>(mVals) { @Override public View getView(FlowLayout parent, int position, SelectTopicRes selectTopicRes) { TextView tv = (TextView) mInflater.inflate(R.layout.circle_conversation_tag_layout, mCircleTfl, false); tv.setText(selectTopicRes.getName()); return tv; } });
public void setOnSelectListener(OnSelectListener onSelectListener) {//选中的条目监听 mOnSelectListener = onSelectListener; } public void setOnTagClickListener(OnTagClickListener onTagClickListener) {//设置条目点击监听 mOnTagClickListener = onTagClickListener; }