今天看一个很有意思的自定义控件给大家分享下,下面直接上干货。
介绍:
有趣的RecyclerView与海绵宝宝字符,海绵宝宝移动他的手和眼睛为ScrollBar的Android。
你可以使用这个列表为孩子应用程序或游戏…你知道。
sdk的最低版本 minSdkVersion=11
Library 大小~ 220 Kb. 是不是很激动
这里写代码片
需求
SDK build-tools 24,从SDK Manager下载。
下载
将此行添加到build.gradle
依赖关系{
compile'com.github.anastr:spongeboblistview:1.0.0'
}}
为maven
<dependency>
<groupId> com.github.anastr </ groupId>
<artifactId> spongeboblistview </ artifactId>
<version> 1.0.0 </ version>
<type> pom </ type>
</ dependency>
用法
添加Speedometer到您的Layout.xml。
<com.github.anastr.spongeboblistview.SpongebobList
android:id =“@ + id / spongebob_list”
android:layout_width =“match_parent”
android:layout_height =“match_parent”/>
使用getRecyclerView()获取RecyclerView,并添加适配器:
SpongebobList spongeList =(SpongebobList)findViewById
(R.id.spongebob_list);
spongeList.getRecyclerView()。setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
spongeList.getRecyclerView()。setLayoutManager(llm);
spongeList.getRecyclerView()。setAdapter(yourAdapter);
属性:
名称功能
spongebob_width海绵宝宝字符的宽度
hand_width海绵的手的宽度
scroll_line_width滚动条的宽度
scroll_line_color滚动条的颜色
好了以上就是关于这开源控件的介绍。
喜欢的可以关注微信公众号,哪里每天都会推荐一篇开源项目Git项目地址在里欢迎订阅