仿美团炫酷动画效果的A-Z字母排序侧边库1

EasySideBar

一款按字母排序的库,已封装好城市数据,可定制化强,也可以下载源代码用Module的形式引入自己改一改来使用,也可稍做改造定制成通讯录。手指触摸选中的屏幕区域,A-Z字母会有偏移动画,防止手指遮挡住字母,很大程度上提升了交互和用户体验度。觉得还不错的话欢迎Star ~

EasySideBar.gif

使用步骤:

1.添加Jcenter仓库 Gradle依赖:

compile 'com.contrarywind:EasySideBar:1.1.0'
   
   
  • 1
  • 1

2.在Activity中添加如下代码:


//热门城市数据 ,不添加数据的时候会隐藏该布局ArrayListhotCityList = new ArrayList<>();

hotCityList.add("北京");

hotCityList.add("上海");

hotCityList.add("广州");

hotCityList.add("深圳");

hotCityList.add("杭州");

hotCityList.add("成都");

hotCityList.add("厦门");

hotCityList.add("天津");

hotCityList.add("武汉");

hotCityList.add("长沙");

//初始化以及配置

new EasySideBarBuilder(MainActivity.this)

.setTitle("城市选择")

/*.setIndexColor(Color.BLUE)*/

.setIndexColor(0xFF0095EE)

/*.isLazyRespond(true) //懒加载模式*/

.setHotCityList(hotCityList)//热门城市列表

.setIndexItems(mIndexItems)//索引字母

.setLocationCity("广州")//定位城市

.setMaxOffset(60)//索引的最大偏移量

.start();

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

3.在Activity中重写onActivityResult方法,接收回调数据:


//resultCode 是使用封装好的EasySideBarBuilder.CODE_SIDEREQUEST

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

switch (requestCode) {

case EasySideBarBuilder.CODE_SIDEREQUEST:

if (data!=null){

String city = data.getStringExtra("selected");

Toast.makeText(this,"选择的城市:"+city,Toast.LENGTH_SHORT).show();

}

break;

default:

break;

}

}

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

GitHub项目地址: EasySideBar

觉得还不错的话,动动手指Star一下呗,抱拳了老铁~
实现原理可下载源代码阅读研究,有疑问之处可随时留言,有问题欢迎Call我。也非常欢迎 Pull Request、 提Issue~

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值