All Projects → TLocation → Flowchooselayout

TLocation / Flowchooselayout

一个基于流体布局的单选 多选控件

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Flowchooselayout

Slidemenulayout
🔥An android slide menu that supports left and right swipes and slides with parallax.(一个支持左右滑动并带有视差滑动效果的安卓侧滑菜单控件.仿[QQ/探探侧滑])
Stars: ✭ 235 (+360.78%)
Mutual labels:  viewgroup
BezierCurtainEffect
贝塞尔曲线窗帘效果BezierCurtainEffect,BezierCurtainView,CurtainEffect,CurtainView
Stars: ✭ 45 (-11.76%)
Mutual labels:  viewgroup
Nestedtouchscrollinglayout
🎱处理子 View,父 View 嵌套滚动,成本比 support v4 NestedScrolling 低,放心食用~
Stars: ✭ 557 (+992.16%)
Mutual labels:  viewgroup
FloatOnKeyboardLayout
The Android layout (ViewGroup) which auto push up when soft keyboard popups。 当软键盘弹出时,界面自动上浮,使界面不会被软键盘遮挡
Stars: ✭ 36 (-29.41%)
Mutual labels:  viewgroup
CoolView
一些炫酷的自定义控件(Some cool custom controls),逐步完善中...
Stars: ✭ 63 (+23.53%)
Mutual labels:  viewgroup
AdapterLayout
ViewGroup backed by RecyclerView.Adapter = magic
Stars: ✭ 58 (+13.73%)
Mutual labels:  viewgroup
Androidpilelayout
An abnormal horizontal ListView-like pile layout with stretch and contraction effects.
Stars: ✭ 2,104 (+4025.49%)
Mutual labels:  viewgroup
Tagviewgroup
Android 仿小红书图片标签Group
Stars: ✭ 891 (+1647.06%)
Mutual labels:  viewgroup
FlowlayoutTags
具有标签功能的流式布局,接口简单。可多选单选,可记住选择状态,状态切换有过渡动画。
Stars: ✭ 78 (+52.94%)
Mutual labels:  viewgroup
Kotlinextensions.com
A handy collection of most commonly used Kotlin extensions to boost your productivity.
Stars: ✭ 522 (+923.53%)
Mutual labels:  viewgroup
SlipperyLayout
A layout that supports sliding.
Stars: ✭ 44 (-13.73%)
Mutual labels:  viewgroup
drag-to-close
Android library that provides a view group which allows to finish an activity by dragging a view.
Stars: ✭ 69 (+35.29%)
Mutual labels:  viewgroup
Swipedelmenulayout
The most simple SwipeMenu in the history, 0 coupling, support any ViewGroup. Step integration swipe (delete) menu, high imitation QQ, iOS. ~史上最简单侧滑菜单,0耦合,支持任意ViewGroup。一步集成侧滑(删除)菜单,高仿QQ、IOS。~
Stars: ✭ 3,376 (+6519.61%)
Mutual labels:  viewgroup
bottomsheets
Material Bottom Sheets library for Android
Stars: ✭ 76 (+49.02%)
Mutual labels:  viewgroup
Android Snake Menu
imitate Tumblr's menu, dragging animations look like a snake
Stars: ✭ 584 (+1045.1%)
Mutual labels:  viewgroup
Cardslidepanel
enable users to slide card to the left or right smoothly and continuously
Stars: ✭ 2,377 (+4560.78%)
Mutual labels:  viewgroup
bubble-layout
An Android ViewGroup that displays avatar bubbles... similar to the chat bubbles on Facebook Messenger.
Stars: ✭ 46 (-9.8%)
Mutual labels:  viewgroup
View shaper
A library to help create shaped views and layouts in Android
Stars: ✭ 42 (-17.65%)
Mutual labels:  viewgroup
Chips Input Layout
A customizable Android ViewGroup for displaying Chips (specified in the Material Design Guide).
Stars: ✭ 591 (+1058.82%)
Mutual labels:  viewgroup
Sliding Panel
Android sliding panel that is part of the view hierarchy, not above it.
Stars: ✭ 433 (+749.02%)
Mutual labels:  viewgroup

FlowChooseLayout

导入

implementation 'com.location:flowChooseLayout:1.0.2'

FlowChooseLayout 是一款 基于流体布局的多选单选控件

FlowChooseLayout自去年11月份发布以来 经历了多次重大版本的更新

  1. 2017年11月 第一版FlowChooseLayout发布只支持setList方式 样式支持TextView

    在今年我们重构了FlowChooseLayout代码 支持任何view 所有样式由开发者自己规划

  2. 2018年8月 我们正式重构了FlowChooseLayout代码

    • 舍弃之前的setList方法
    • 全局使用适配器方法,采用观察者模式 一个适配器控制多个FlowLayout
    • 重写了之前权重的逻辑 可以像Lainlayout根据当前的布局找到更合适的大小而不是于之前采用最大权重的方式
    • 内部舍弃创建view 目前FlowChooseLayout只参与view的展示与点击
    • 对于之前的addView方式 我们并不是一竿子打掉 两种方式随意切换

    效果

使用方式

在xml声明

<com.loction.choose.flowchooselibrary.weight.FlowChooseLayout
	android:id="@+id/id_attr"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	app:flow="true"
	app:isMultiSelect="true"
	app:rowSpacing="10dp"
	app:childSpacing="10dp"/>

自定义属性

<declare-styleable name="FlowChooseLayout">
		<!--是否流体布局-->
		<attr name="flow" format="boolean" />
		<!--每个view之间宽度 如果设置权重则此效果无效-->
		<attr name="childSpacing" format="enum|dimension">
			<enum name="auto" value="-65536" />
		</attr>
		<!--最后一行字view的间距-->
		<attr name="childSpacingForLastRow" format="enum|dimension">
			<enum name="auto" value="-65536" />
			<enum name="align" value="-65537" />
		</attr>
		<attr name="rowSpacing" format="enum|dimension">
			<enum name="auto" value="-65536" />
		</attr>
		<!--排列方式 是否从右边开始布局  默认左边-->
		<attr name="rtl" format="boolean" />
		<attr name="maxRows" format="integer" />
		<!--设置权重  则宽度必须为math或者固定数值-->
		<attr name="weight" format="boolean" />
		<!--均分数目   weight为false时无效-->
		<attr name="weightNum" format="integer" />
		<!--设定是否多选 默认为单选-->
		<attr name="isMultiSelect" />
		<!--是否使用适配器模式-->
		<attr name="adapter"/>
	</declare-styleable>

java代码 自定义adaptetr继承FlowAdapter 类

public class MyAdapter extends FlowAdapter<DataBean> {

    /**
    * 实现默认的构造方法
    */
	public MyAdapter(List<DataBean> data) {
		super(data);
	}

    /**
    *   重写getView 方法  构造view
    *   形参 view不等于null的时候只有在刷新数据的时候不为空  其余一律为空
    */
	@Override
	public View getView(ViewGroup parent, View view, int position) {
		View contentView = null;
		if (view != null) {
			contentView = view;
		} else {
			contentView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_flow, parent, false);
		}
		TextView textView = contentView.findViewById(R.id.view_content);
		textView.setText(data.get(position).getName());
		return contentView;
	}


    /**
    *  当view状态改变的时候调用此方法
    
       state  true  选中
              false  不选中
    */
	@Override
	public void onChangeState(View view, int position, boolean state) {
		TextView textView = view.findViewById(R.id.view_content);
		if (state) {
			view.setBackgroundColor(Color.RED);
			textView.setText("已开启");
		} else {
			view.setBackgroundColor(Color.BLUE);
			textView.setText("选择");
		}

	}
}

设置适配器

final FlowChooseLayout flowChooseLayout = findViewById(R.id.id_attr);
		final List<DataBean> list = new ArrayList<>();
		String[] stringArray = getResources().getStringArray(R.array.flow_demo);
		for (int i = 0; i < stringArray.length; i++) {
			DataBean dataBean = new DataBean();
dataBean.setName(stringArray[i]);
			list.add(dataBean);
		}
        //初始化适配器
		myAdapter = new MyAdapter(list);
       //设置默认选中
		flowChooseLayout.setDefaultCheckd(0);
       //设置适配器
		flowChooseLayout.setAdapter(myAdapter);

      findViewById(R.id.id_btn).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
                //增加数据  刷新适配器
				DataBean dataBean = new DataBean();
				dataBean.setName("增加选中项");
				list.add(dataBean);
				myAdapter.notifyDataSetChanged();
			}
		});


		findViewById(R.id.id_clear).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
                //获取已经选中的索引
				List<Integer> allCheckedIndex = flowChooseLayout.getAllCheckedIndex();
				LogUtils.i("choose===>" + "选中===》" + allCheckedIndex.toString());
				textView.setText("已经选中的索引\n");
				textView.append(allCheckedIndex.toString());
			}
		});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].