Skip to content

⛵FlowView是一款流布局控件,采用Adapter模式,可以自定义item,更加灵活,使用起来就和ListView与BaseAdapter搭配一样简单,提供各种对齐方式,可以自适应 高度,也可以设置item的高度,可以控制item的最大显示行数...

albert-lii/FlowView

Repository files navigation

FlowView

releasesvg apisvg license

关于

FlowView是一款流布局控件,采用Adapter模式,可以自定义item,更加灵活,使用起来就和ListView与BaseAdapter搭配一样简单,提供各种对齐方式,可以自适应高度,也可以设置item的高度,可以控制item的最大显示行数...

演示

先来看看效果吧!

演示

添加依赖

  • 使用Gradle
  // 注:如果添加依赖成功,则此句不必添加,此句作用仅为当项目在被审核时,紧急需要使用时添加
   allprojects {
       repositories {
           ...
           // 如果添加依赖时,报找不到项目时(项目正在审核),可以添加此句maven地址,如果找到项目,可不必添加
           maven { url "https://dl.bintray.com/albertlii/android-maven/" }
       }
    }
    
    dependencies {
         compile 'com.liyi.view:flowview:1.2.2'
    }
  • 使用Maven
 <dependency>
   <groupId>com.liyi.view</groupId>
   <artifactId>flowview</artifactId>
   <version>1.2.2</version>
   <type>pom</type>
 </dependency>

自定义属性

  • flow_horizontalAlign(item 在一行中的横向对齐方式,默认为 left)  - left(item 左对齐)

    • middle(item 横向居中对齐)
    • right(item 右对齐)
  • flow_verticalAlign(item 在一行中的纵向对齐方式,默认为 middle,当设置 flow_height 时,此属性无效)  

    • top(item 上对齐)
    • middle(item 纵向居中对齐)
    • bottom(item 底部对齐)
  • flow_height(流布局的 item 的高度,默认为自适应)

  • flow_horizontalSpace(流布局的 item 横向间距,默认为 10px)

  • flow_verticalSpace(流布局的 item 纵向间距,默认为 10px)

  • flow_maxRow(流布局最多显示的行数,默认为不限制)

使用方法

XML 中 添加 FlowView

 <com.liyi.flow.FlowView
    android:id="@+id/flowVi"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

代码中使用 FlowView

三种适配器

简单示例

注:此处使用的是 SimpleFlowAdapterSimpleFlowAdapter 必须设置 setLoadData() 来处理数据
 mAdapter = new SimpleFlowAdapter(mList);
 mAdapter.setLoadData(new SimpleFlowAdapter.LoadData<String>() {
      @Override
      public void onLoadData(int position, String item, TextView textView) {
           textView.setText(item);
      }
});
flowView.setAdapter(mAdapter);
// 单击事件
flowView.setOnItemClickListener(new FlowView.OnItemClickListener() {
    @Override
    public void onItemClick(int position, View view) {
        Toast.makeText(SimpleFlowActivity.this, "我是" + position + "号", Toast.LENGTH_SHORT).show();
    }
});

赞赏

如果你感觉 FlowView 帮助到了你,可以点右上角 "Star" 支持一下哦!:blush:

LICENSE

Copyright 2017 liyi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

⛵FlowView是一款流布局控件,采用Adapter模式,可以自定义item,更加灵活,使用起来就和ListView与BaseAdapter搭配一样简单,提供各种对齐方式,可以自适应 高度,也可以设置item的高度,可以控制item的最大显示行数...

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages