转载请注明出处:王亟亟的大牛之路
最近一直在写混合开发的东西,是时候温故下native的了。
一年多之前领导提了一个双性滚动+快点击的”TableView”那时候自己整了2 3天没整出来,本来想今天”圆梦”,但是发现轮子已经有了,但是少了一些小功能和足够多的解释,那就把这个轮子fork下来自己改!(我们不生产代码,我们只是代码的搬运工)
源码地址:https://github.com/ddwhan0123/ScrollTableView
按照习惯,安利下:https://github.com/ddwhan0123/Useful-Open-Source-Android (今天把search view也划分了出去)
效果图:
可以滚动,可以点击,基本满足了之前的要求
包结构:东西也不是很多,copy也不复杂
本文会详细的”拆”这个库
如何引用:
<com.loopeer.android.librarys.scrolltable.ScrollTableView
android:id="@+id/scroll_table_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
正常控件用就行了,没什么特别的姿势,这边讲下有哪些自定义标签
都在ScrollTable/src/main/res/values/attrs.xml里
dataMargin 数据间距 类型:dimension
itemHeight 每个块的高度 类型:dimension
itemWidth 每个块的宽度 类型:dimension
topPlaceHeight 头部的高度 类型:dimension
itemIndicatorCircleRadius 小圆圈的半径 类型:dimension
itemIndicatorLineWidth 分割线的宽度 类型:dimension
textTitleSize 标题大小 类型:dimension
textLeftTitleColor 左边标题颜色 类型:dimension
textTopTitleColor 上边标题颜色 类型:dimension
等等等。。。(一排可以自己看,不难理解)
组成
很明显,这是一个试图组,这边拆一下,给大家解释下
ScrollTable/src/main/res/layout/view_container.xml里
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.loopeer.android.librarys.scrolltable.view.IHorizontalScrollView
android:id="@+id/scroll_header_horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/table_top_title_height"
android:layout_marginLeft="@dimen/table_left_title_width"
>
<com.loopeer.android.librarys.scrolltable.view.TopTitleView
android:id="@+id/header_horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</com.loopeer.android.librarys.scrolltable.view.IHorizontalScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<com.loopeer.android.librarys.scrolltable.view.VerticalScrollView
android:id="@+id/scroll_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"