├── .gitignore
├── README.md
├── ScrollTable
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── loopeer
│ │ └── android
│ │ └── librarys
│ │ └── scrolltable
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── loopeer
│ │ └── android
│ │ └── librarys
│ │ └── scrolltable
│ │ ├── CustomTableView.java
│ │ ├── IHorizontalScrollView.java
│ │ ├── IScroller.java
│ │ ├── LeftTitleView.java
│ │ ├── Position.java
│ │ ├── ScrollTableView.java
│ │ ├── TopTitleView.java
│ │ └── VerticalScrollView.java
│ └── res
│ ├── layout
│ ├── list_item_text.xml
│ └── view_container.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ └── strings.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── loopeer
│ │ └── android
│ │ └── librarys
│ │ └── horizontalverticalscrollview
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── loopeer
│ │ └── android
│ │ └── librarys
│ │ └── horizontalverticalscrollview
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ ├── activity_main.xml
│ └── list_item_text.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot
├── screenshot.gif
├── screenshot1.png
└── screenshot3.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Specific files to exclude
2 | dist
3 | com_crashlytics_export_strings.xml
4 | keys.xml
5 | #*.keystore
6 |
7 | ### Android
8 | ###########
9 | # built application files
10 | *.apk
11 | *.ap_
12 |
13 | # files for the dex VM
14 | *.dex
15 |
16 | # Java class files
17 | *.class
18 |
19 | # generated files
20 | bin/
21 | gen/
22 |
23 | # Local configuration file (sdk path, etc)
24 | local.properties
25 | gradle.properties
26 | keystore.properties
27 |
28 | ### Mac
29 | .DS_store
30 |
31 | ### Linux
32 | #########
33 | !.gitignore
34 | *~
35 |
36 | ### Windows
37 | ############
38 | # Windows image file caches
39 | Thumbs.db
40 | ehthumbs.db
41 |
42 | # Folder config file
43 | Desktop.ini
44 |
45 | # Recycle Bin used on file shares
46 | $RECYCLE.BIN/
47 |
48 | ### IntelliJ
49 | *.iml
50 | *.ipr
51 | *.iws
52 | .idea/
53 |
54 | ### Gradle
55 | .gradle/
56 | build/
57 | out/
58 |
59 | #Maven
60 | target
61 | release.properties
62 | pom.xml.*
63 |
64 | ### AppEngine
65 | google_generated/
66 | datanucleus.log
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ScrollTableView
2 |
3 | Screeshot
4 | ====
5 | 
6 |
--------------------------------------------------------------------------------
/ScrollTable/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ScrollTable/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 | version = "1.0.0"
5 |
6 | android {
7 | compileSdkVersion 23
8 | buildToolsVersion "23.0.1"
9 |
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 23
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | compile 'com.android.support:appcompat-v7:23.0.1'
27 | }
28 |
29 | def siteUrl = 'https://github.com/loopeer/ScrollTableView' // 项目的主页
30 | def gitUrl = 'https://github.com/loopeer/ScrollTableView.git' // Git仓库的url
31 | group = "com.loopeer.library"
32 | install {
33 | repositories.mavenInstaller {
34 | // This generates POM.xml with proper parameters
35 | pom {
36 | project {
37 | packaging 'aar'
38 | // Add your description here
39 | name 'Custom table can scroll vertical and horizontal' //项目描述
40 | url siteUrl
41 | // Set your license
42 | licenses {
43 | license {
44 | name 'The Apache Software License, Version 2.0'
45 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
46 | }
47 | }
48 | developers {
49 | developer {
50 | id 'ToDou' //填写开发者基本信息
51 | name 'ToDou'
52 | email 'yytodou123@gmail.com'
53 | }
54 | }
55 | scm {
56 | connection gitUrl
57 | developerConnection gitUrl
58 | url siteUrl
59 | }
60 | }
61 | }
62 | }
63 | }
64 | task sourcesJar(type: Jar) {
65 | from android.sourceSets.main.java.srcDirs
66 | classifier = 'sources'
67 | }
68 | task javadoc(type: Javadoc) {
69 | source = android.sourceSets.main.java.srcDirs
70 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
71 | }
72 | task javadocJar(type: Jar, dependsOn: javadoc) {
73 | classifier = 'javadoc'
74 | from javadoc.destinationDir
75 | }
76 | artifacts {
77 | archives javadocJar
78 | archives sourcesJar
79 | }
80 | Properties properties = new Properties()
81 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
82 | bintray {
83 | user = properties.getProperty("bintray.user")
84 | key = properties.getProperty("bintray.apikey")
85 | configurations = ['archives']
86 | pkg {
87 | repo = "maven" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
88 | name = "scrolltableview" //发布到Bintray上的项目名字
89 | websiteUrl = siteUrl
90 | vcsUrl = gitUrl
91 | licenses = ["Apache-2.0"]
92 | publish = true
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ScrollTable/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/todou/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/ScrollTable/src/androidTest/java/com/loopeer/android/librarys/scrolltable/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/ScrollTable/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/CustomTableView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.support.v4.content.ContextCompat;
8 | import android.util.AttributeSet;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import java.util.ArrayList;
12 |
13 | public class CustomTableView extends View {
14 | private static final String TAG = "CustomTableView";
15 |
16 | private Paint mPaintTextNormal;
17 | private Paint mPaintItemBg;
18 |
19 | private int mTextUnableColor;
20 | private int mTextNormalColor;
21 | private int mTextSelectColor;
22 | private int mItemBgNormalColor;
23 | private int mItemBgSelectColor;
24 | private float mTextNormal;
25 |
26 | private int mItemHeight;
27 | private int mItemWidth;
28 | private int mItemMargin;
29 | private ArrayList> datas;
30 |
31 | private int row = 20;
32 | private int column = 10;
33 |
34 | private ArrayList selectPositions;
35 | private OnPositionClickListener mPositionChangeListener;
36 |
37 | public CustomTableView(Context context) {
38 | this(context, null);
39 | }
40 |
41 | public CustomTableView(Context context, AttributeSet attrs) {
42 | this(context, attrs, 0);
43 | }
44 |
45 | public CustomTableView(Context context, AttributeSet attrs, int defStyleAttr) {
46 | super(context, attrs, defStyleAttr);
47 |
48 | init(context, attrs, defStyleAttr);
49 | setBackgroundColor(ContextCompat.getColor(getContext(), R.color.table_divider_color));
50 | }
51 |
52 | private void init(Context context, AttributeSet attrs, int defStyleAttr) {
53 | initData();
54 | initPaint();
55 | datas = new ArrayList<>();
56 | selectPositions = new ArrayList<>();
57 | }
58 |
59 | private void initData() {
60 | mItemHeight = getResources().getDimensionPixelSize(R.dimen.table_item_height);
61 | mItemWidth = getResources().getDimensionPixelSize(R.dimen.table_item_width);
62 | mItemMargin = getResources().getDimensionPixelSize(R.dimen.table_item_margin);
63 | }
64 |
65 | private void initPaint() {
66 | mTextNormalColor = ContextCompat.getColor(getContext(), R.color.table_text_normal_color);
67 | mTextUnableColor = ContextCompat.getColor(getContext(), R.color.table_text_unable_color);
68 | mTextSelectColor = ContextCompat.getColor(getContext(), R.color.table_text_select_color);
69 | mItemBgNormalColor = ContextCompat.getColor(getContext(), R.color.table_item_bg_normal_color);
70 | mItemBgSelectColor = ContextCompat.getColor(getContext(), R.color.table_item_bg_select_color);
71 | mTextNormal = getResources().getDimension(R.dimen.table_default_text_size);
72 |
73 | mPaintTextNormal = new Paint(Paint.ANTI_ALIAS_FLAG);
74 | mPaintTextNormal.setColor(mTextNormalColor);
75 | mPaintTextNormal.setTextSize(mTextNormal);
76 |
77 | mPaintItemBg = new Paint(Paint.ANTI_ALIAS_FLAG);
78 | mPaintItemBg.setColor(mItemBgNormalColor);
79 | mPaintItemBg.setStyle(Paint.Style.FILL);
80 | }
81 |
82 | @Override
83 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
84 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
85 |
86 | setMeasuredDimension(column * mItemWidth + (column - 1) * mItemMargin, row * mItemHeight + row * mItemMargin);
87 | }
88 |
89 | @Override
90 | protected void onDraw(Canvas canvas) {
91 | super.onDraw(canvas);
92 |
93 | drawItem(canvas);
94 |
95 | }
96 |
97 | private void drawItem(Canvas canvas) {
98 | for (int rowIndex = 0; rowIndex < row; rowIndex++) {
99 | for (int columnIndex = 0; columnIndex < column; columnIndex++) {
100 | adJustSelectPaintColor(columnIndex, rowIndex);
101 |
102 | float left = mItemWidth * columnIndex + mItemMargin * columnIndex;
103 | float right = left + mItemWidth;
104 | float top = mItemHeight * rowIndex + mItemMargin * (rowIndex + 1);
105 | float bottom = top + mItemHeight;
106 | canvas.drawRect(left, top, right, bottom, mPaintItemBg);
107 |
108 | String content = getShowData(rowIndex, columnIndex);
109 | Paint.FontMetrics fontMetrics = mPaintTextNormal.getFontMetrics();
110 | float fontHeight = fontMetrics.bottom - fontMetrics.top;
111 | float textWidth = mPaintTextNormal.measureText(content);
112 | float y = top + mItemHeight - (mItemHeight - fontHeight) / 2 - fontMetrics.bottom;
113 | float x = left + mItemWidth / 2 - textWidth / 2;
114 |
115 | canvas.drawText(content, x, y, mPaintTextNormal);
116 | }
117 | }
118 | }
119 |
120 | private String getShowData(int rowIndex, int columnIndex) {
121 | if (datas.size() > rowIndex) {
122 | return datas.get(rowIndex).size() > columnIndex ? datas.get(rowIndex).get(columnIndex) : "";
123 | } else {
124 | return "";
125 | }
126 | }
127 |
128 | private void adJustSelectPaintColor(int columnIndex, int rowIndex) {
129 | if (selectPositions != null && selectPositions.contains(new Position(columnIndex, rowIndex))) {
130 | mPaintTextNormal.setColor(mTextSelectColor);
131 | mPaintItemBg.setColor(mItemBgSelectColor);
132 | } else {
133 | mPaintTextNormal.setColor(mTextNormalColor);
134 | mPaintItemBg.setColor(mItemBgNormalColor);
135 | }
136 | }
137 |
138 | public void setRowAndColumn(int row, int column) {
139 | this.row = row;
140 | this.column = column;
141 | invalidate();
142 | }
143 |
144 | public void setDatas(ArrayList> data) {
145 | datas.clear();
146 | for (ArrayList rowArrayString : data) {
147 | datas.add(rowArrayString);
148 | }
149 | invalidate();
150 | }
151 |
152 | public void setOnPositionChangeListener(OnPositionClickListener listener) {
153 | mPositionChangeListener = listener;
154 | }
155 |
156 | public void setSelectPositions(ArrayList positions) {
157 | selectPositions.clear();
158 | selectPositions.addAll(positions);
159 | invalidate();
160 | }
161 |
162 | public boolean onTouchEvent(MotionEvent event) {
163 | Position position = getPositionFromLocation(event.getX(), event.getY());
164 | if (position == null) {
165 | return true;
166 | }
167 | switch (event.getAction()) {
168 | case MotionEvent.ACTION_DOWN:
169 |
170 | break;
171 | case MotionEvent.ACTION_UP:
172 | if (mPositionChangeListener != null) {
173 | mPositionChangeListener.onPositionClick(position);
174 | }
175 | break;
176 | }
177 | return true;
178 | }
179 |
180 | public Position getPositionFromLocation(float x, float y) {
181 |
182 | if (x > getWidth()) {
183 | return null;
184 | }
185 |
186 | if (y > getHeight()) {
187 | return null;
188 | }
189 |
190 | int yPosition = (int) y / (mItemHeight + mItemMargin);
191 |
192 | int xPosition = (int) (x / (mItemWidth + mItemMargin));
193 |
194 | return new Position(xPosition, yPosition);
195 | }
196 |
197 | public interface OnPositionClickListener {
198 | void onPositionClick(Position position);
199 | }
200 |
201 | public void setItemHeight(int height) {
202 | mItemHeight = height;
203 | invalidate();
204 | }
205 |
206 | public void setItemWidth(int width) {
207 | mItemWidth = width;
208 | invalidate();
209 | }
210 |
211 | public void setItemMargin(int margin) {
212 | mItemMargin = margin;
213 | invalidate();
214 | }
215 |
216 | public void setColors(int... colors) {
217 | if (colors.length > 0) mTextNormalColor = colors[0];
218 | if (colors.length > 1) mTextSelectColor = colors[1];
219 | if (colors.length > 2) mTextUnableColor = colors[2];
220 | invalidate();
221 | }
222 |
223 | public void setTextNormalColor(int color) {
224 | mTextNormalColor = color;
225 | invalidate();
226 | }
227 |
228 | public void setTextSelectColor(int color) {
229 | mTextSelectColor = color;
230 | invalidate();
231 | }
232 |
233 | public void setTextUnableColor(int color) {
234 | mTextUnableColor = color;
235 | invalidate();
236 | }
237 |
238 | public void setUpAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
239 | if (attrs == null) return;
240 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrollTableView, defStyleAttr, 0);
241 | if (a == null) return;
242 |
243 | setItemHeight(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemHeight, mItemHeight));
244 | setItemWidth(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemWidth, mItemWidth));
245 | setItemMargin(a.getDimensionPixelSize(R.styleable.ScrollTableView_dataMargin, mItemMargin));
246 | setTextNormalColor(a.getColor(R.styleable.ScrollTableView_textNormalColor, mTextNormalColor));
247 | setTextSelectColor(a.getColor(R.styleable.ScrollTableView_textSelectColor, mTextSelectColor));
248 | setTextUnableColor(a.getColor(R.styleable.ScrollTableView_textUnableColor, mTextUnableColor));
249 |
250 | }
251 | }
252 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/IHorizontalScrollView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.HorizontalScrollView;
6 |
7 | public class IHorizontalScrollView extends HorizontalScrollView implements IScroller{
8 |
9 | private IScroller scroller;
10 |
11 | public IHorizontalScrollView(Context context) {
12 | this(context, null);
13 | }
14 |
15 | public IHorizontalScrollView(Context context, AttributeSet attrs) {
16 | this(context, attrs, 0);
17 | }
18 |
19 | public IHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
20 | super(context, attrs, defStyleAttr);
21 |
22 | }
23 |
24 | @Override
25 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
26 | super.onScrollChanged(l, t, oldl, oldt);
27 |
28 | if (scroller != null) {
29 | scroller.onScrollXY(l, t);
30 | }
31 | }
32 |
33 | public void setIScroller(IScroller scroller) {
34 | this.scroller = scroller;
35 | }
36 |
37 | @Override
38 | public void onScrollXY(int offsetX, int offsetY) {
39 | scrollTo(offsetX, offsetY);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/IScroller.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | public interface IScroller {
4 |
5 | void onScrollXY(int offsetX, int offsetY);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/LeftTitleView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.support.v4.content.ContextCompat;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.View;
11 |
12 | import java.util.ArrayList;
13 |
14 | public class LeftTitleView extends View {
15 |
16 | private Paint mPaintTextNormal;
17 | private Paint mPaintItemIndicatorCircle;
18 | private Paint mPaintItemIndicatorLine;
19 |
20 | private int mTextLeftTitleColor;
21 | private int mItemIndicatorColor;
22 | private float mTextTitleSize;
23 |
24 | private int mItemHeight;
25 | private int mItemWidth;
26 | private int mItemMargin;
27 | private int row;
28 | private int mItemIndicatorCircleRadius;
29 | private int mItemIndicatorLineWidth;
30 |
31 | ArrayList titles;
32 |
33 | public LeftTitleView(Context context) {
34 | this(context, null);
35 | }
36 |
37 | public LeftTitleView(Context context, AttributeSet attrs) {
38 | this(context, attrs, 0);
39 | }
40 |
41 | public LeftTitleView(Context context, AttributeSet attrs, int defStyleAttr) {
42 | super(context, attrs, defStyleAttr);
43 |
44 | init(context, attrs, defStyleAttr);
45 | }
46 |
47 | private void init(Context context, AttributeSet attrs, int defStyleAttr) {
48 | initData();
49 | initPaint();
50 | titles = new ArrayList<>();
51 | }
52 |
53 | private void initData() {
54 | mItemHeight = getResources().getDimensionPixelSize(R.dimen.table_item_height);
55 | mItemWidth = getResources().getDimensionPixelSize(R.dimen.table_item_width);
56 | mItemMargin = getResources().getDimensionPixelSize(R.dimen.table_item_margin);
57 | mItemIndicatorCircleRadius = getResources().getDimensionPixelSize(R.dimen.table_header_circle_radius);
58 | mItemIndicatorLineWidth = getResources().getDimensionPixelSize(R.dimen.table_header_indicator_width);
59 | }
60 |
61 | private void initPaint() {
62 | mTextLeftTitleColor = ContextCompat.getColor(getContext(), R.color.table_text_secondary_color);
63 | mItemIndicatorColor = ContextCompat.getColor(getContext(), R.color.table_divider_color);
64 | mTextTitleSize = getResources().getDimension(R.dimen.table_default_title_size);
65 |
66 | mPaintTextNormal = new Paint(Paint.ANTI_ALIAS_FLAG);
67 | mPaintTextNormal.setColor(mTextLeftTitleColor);
68 | mPaintTextNormal.setTextSize(mTextTitleSize);
69 |
70 | mPaintItemIndicatorCircle = new Paint(Paint.ANTI_ALIAS_FLAG);
71 | mPaintItemIndicatorCircle.setColor(mItemIndicatorColor);
72 | mPaintItemIndicatorCircle.setStyle(Paint.Style.FILL);
73 |
74 |
75 | mPaintItemIndicatorLine = new Paint(Paint.ANTI_ALIAS_FLAG);
76 | mPaintItemIndicatorLine.setColor(mItemIndicatorColor);
77 | mPaintItemIndicatorLine.setStyle(Paint.Style.FILL);
78 | }
79 |
80 | @Override
81 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
82 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
83 | int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
84 | mItemWidth = sizeWidth;
85 | setMeasuredDimension(mItemWidth, row * mItemHeight + (row + 1) * mItemMargin);
86 | }
87 |
88 | @Override
89 | protected void onDraw(Canvas canvas) {
90 | super.onDraw(canvas);
91 | drawItem(canvas);
92 | }
93 |
94 | private void drawItem(Canvas canvas) {
95 | for (int rowIndex = 0; rowIndex < row; rowIndex++) {
96 | String content = titles.get(rowIndex);
97 | Paint.FontMetrics fontMetrics = mPaintTextNormal.getFontMetrics();
98 | float fontHeight = fontMetrics.bottom - fontMetrics.top;
99 | float textWidth = mPaintTextNormal.measureText(content);
100 | float y = rowIndex * (mItemHeight + mItemMargin) + mItemHeight - (mItemHeight - fontHeight) / 2 - fontMetrics.bottom - mItemHeight / 2 + getResources().getDimension(R.dimen.table_default_margin_top) - mItemMargin / 2 + mItemMargin;
101 |
102 | float x = mItemWidth - textWidth - 2 * mItemIndicatorCircleRadius - mItemIndicatorLineWidth - 12;
103 |
104 | canvas.drawText(content, x, y, mPaintTextNormal);
105 |
106 | canvas.drawCircle(mItemWidth - mItemIndicatorLineWidth - mItemIndicatorCircleRadius,
107 | rowIndex * (mItemHeight + mItemMargin) + getResources().getDimension(R.dimen.table_default_margin_top) - mItemMargin / 2 + mItemMargin,
108 | mItemIndicatorCircleRadius, mPaintItemIndicatorCircle);
109 |
110 | canvas.drawRect(mItemWidth - mItemIndicatorLineWidth,
111 | rowIndex * (mItemHeight + mItemMargin) + getResources().getDimension(R.dimen.table_default_margin_top) - mItemMargin / 2 - mItemMargin / 2 + mItemMargin,
112 | mItemWidth,
113 | rowIndex * (mItemHeight + mItemMargin) + getResources().getDimension(R.dimen.table_default_margin_top) - mItemMargin / 2 + mItemMargin / 2 + mItemMargin,
114 | mPaintItemIndicatorLine);
115 | }
116 | }
117 |
118 | public void updateTitles(ArrayList data) {
119 | titles.clear();
120 | titles.addAll(data);
121 | updateView();
122 | }
123 |
124 | private void updateView() {
125 | invalidate();
126 | row = titles.size();
127 | }
128 |
129 | public void setItemHeight(int height) {
130 | mItemHeight = height;
131 | invalidate();
132 | }
133 |
134 | public void setItemWidth(int width) {
135 | mItemWidth = width;
136 | invalidate();
137 | }
138 |
139 | public void setItemMargin(int margin) {
140 | mItemMargin = margin;
141 | invalidate();
142 | }
143 |
144 | public void setTextLeftTitleColor(int color) {
145 | mTextLeftTitleColor = color;
146 | mPaintTextNormal.setColor(mTextLeftTitleColor);
147 | invalidate();
148 | }
149 |
150 | public void setItemIndicatorColor(int color) {
151 | mItemIndicatorColor = color;
152 | mPaintItemIndicatorLine.setColor(mItemIndicatorColor);
153 | mPaintItemIndicatorCircle.setColor(mItemIndicatorColor);
154 | invalidate();
155 | }
156 |
157 | public void setIndicatorCircleRadius(int radius) {
158 | mItemIndicatorCircleRadius = radius;
159 | invalidate();
160 | }
161 |
162 | public void setItemIndicatorLineWidth(int width) {
163 | mItemIndicatorLineWidth = width;
164 | invalidate();
165 | }
166 |
167 | public void setPaintTextNormalSize(float size) {
168 | mTextTitleSize = size;
169 | mPaintTextNormal.setTextSize(mTextTitleSize);
170 | invalidate();
171 | }
172 |
173 | public void setUpAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
174 | if (attrs == null) return;
175 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrollTableView, defStyleAttr, 0);
176 | if (a == null) return;
177 |
178 | setItemHeight(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemHeight, mItemHeight));
179 | setItemWidth(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemWidth, mItemWidth));
180 | setItemMargin(a.getDimensionPixelSize(R.styleable.ScrollTableView_dataMargin, mItemMargin));
181 | setTextLeftTitleColor(a.getColor(R.styleable.ScrollTableView_textLeftTitleColor, mTextLeftTitleColor));
182 | setItemIndicatorColor(a.getColor(R.styleable.ScrollTableView_itemIndicatorColor, mItemIndicatorColor));
183 | setIndicatorCircleRadius(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemIndicatorCircleRadius, mItemIndicatorCircleRadius));
184 | setItemIndicatorLineWidth(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemIndicatorLineWidth, mItemIndicatorLineWidth));
185 | setPaintTextNormalSize(a.getDimension(R.styleable.ScrollTableView_textTitleSize, mTextTitleSize));
186 |
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/Position.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | public class Position {
4 |
5 | public int x;
6 | public int y;
7 |
8 | public String getPositionString() {
9 | return Integer.toString(x) + ":" + Integer.toString(y);
10 | }
11 |
12 | public Position(int x, int y) {
13 | this.x = x;
14 | this.y = y;
15 | }
16 |
17 | @Override
18 | public boolean equals(Object o) {
19 | if (!(o instanceof Position)) {
20 | return false;
21 | } else {
22 | return x == ((Position)o).x && y == ((Position)o).y;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/ScrollTableView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.widget.LinearLayout;
8 | import java.util.ArrayList;
9 |
10 | public class ScrollTableView extends LinearLayout implements CustomTableView.OnPositionClickListener {
11 |
12 | private IHorizontalScrollView scrollHeaderHorizontal;
13 | private IHorizontalScrollView scrollHorizontal;
14 | private LeftTitleView headerVertical;
15 | private TopTitleView headerHorizontal;
16 | private CustomTableView contentView;
17 | private ArrayList selectPositions;
18 | private ArrayList topTitles;
19 | private ArrayList leftTitles;
20 | private ArrayList> datas;
21 |
22 | public ScrollTableView(Context context) {
23 | this(context, null);
24 | }
25 |
26 | public ScrollTableView(Context context, AttributeSet attrs) {
27 | this(context, attrs, 0);
28 | }
29 |
30 | public ScrollTableView(Context context, AttributeSet attrs, int defStyleAttr) {
31 | super(context, attrs, defStyleAttr);
32 | init(context, attrs, defStyleAttr);
33 | }
34 |
35 | private void init(Context context, AttributeSet attrs, int defStyleAttr) {
36 | LayoutInflater.from(context).inflate(R.layout.view_container, this);
37 | setUpView();
38 | setUpData();
39 | selectPositions = new ArrayList<>();
40 |
41 |
42 | if (attrs == null) return;
43 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrollTableView, defStyleAttr, 0);
44 | if (a == null) return;
45 |
46 | headerVertical.setUpAttrs(context, attrs, defStyleAttr);
47 | headerHorizontal.setUpAttrs(context, attrs, defStyleAttr);
48 | contentView.setUpAttrs(context, attrs, defStyleAttr);
49 |
50 | a.recycle();
51 | }
52 |
53 | private void setUpView() {
54 | scrollHeaderHorizontal = (IHorizontalScrollView) findViewById(R.id.scroll_header_horizontal);
55 | scrollHorizontal = (IHorizontalScrollView) findViewById(R.id.scroll_horizontal);
56 | headerVertical = (LeftTitleView) findViewById(R.id.header_vertical);
57 | headerHorizontal = (TopTitleView) findViewById(R.id.header_horizontal);
58 | contentView = (CustomTableView) findViewById(R.id.content_view);
59 | scrollHorizontal.setIScroller(scrollHeaderHorizontal);
60 | scrollHeaderHorizontal.setIScroller(scrollHorizontal);
61 | }
62 |
63 | public LeftTitleView getLeftTitleView() {
64 | return headerVertical;
65 | }
66 |
67 | public TopTitleView getTopTitleView() {
68 | return headerHorizontal;
69 | }
70 |
71 | public CustomTableView getContentView() {
72 | return contentView;
73 | }
74 |
75 | private void setUpData() {
76 | leftTitles = new ArrayList<>();
77 | topTitles = new ArrayList<>();
78 | datas = new ArrayList<>();
79 | contentView.setRowAndColumn(leftTitles.size(), topTitles.size());
80 | contentView.setOnPositionChangeListener(this);
81 | }
82 |
83 | public void setDatas(ArrayList topTitlesData, ArrayList leftTitlesData, ArrayList> itemData) {
84 | topTitles.clear();
85 | leftTitles.clear();
86 | datas.clear();
87 | topTitles.addAll(topTitlesData);
88 | leftTitles.addAll(leftTitlesData);
89 | datas.addAll(itemData);
90 | updateView();
91 | }
92 |
93 | private void updateView() {
94 | headerVertical.updateTitles(leftTitles);
95 | headerHorizontal.updateTitles(topTitles);
96 | contentView.setRowAndColumn(leftTitles.size(), topTitles.size());
97 | contentView.setDatas(datas);
98 | }
99 |
100 | @Override
101 | public void onPositionClick(Position position) {
102 | if (selectPositions.contains(position)) {
103 | selectPositions.remove(position);
104 | } else {
105 | selectPositions.add(position);
106 | }
107 | contentView.setSelectPositions(selectPositions);
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/TopTitleView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.support.v4.content.ContextCompat;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import java.util.ArrayList;
11 |
12 | public class TopTitleView extends View {
13 |
14 | private Paint mPaintTextNormal;
15 | private int mTextTopTitleColor;
16 | private float mTextNormal;
17 |
18 | private int mItemHeight;
19 | private int mItemPlaceHeight;
20 | private int mItemWidth;
21 | private int mItemMargin;
22 | private int column;
23 |
24 | private ArrayList titles;
25 |
26 | public TopTitleView(Context context) {
27 | this(context, null);
28 | }
29 |
30 | public TopTitleView(Context context, AttributeSet attrs) {
31 | this(context, attrs, 0);
32 | }
33 |
34 | public TopTitleView(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 |
37 | init(context, attrs, defStyleAttr);
38 | }
39 |
40 | private void init(Context context, AttributeSet attrs, int defStyleAttr) {
41 | initData();
42 | initPaint();
43 | titles = new ArrayList<>();
44 | }
45 |
46 | private void initData() {
47 | mItemHeight = getResources().getDimensionPixelSize(R.dimen.table_item_height);
48 | mItemWidth = getResources().getDimensionPixelSize(R.dimen.table_item_width);
49 | mItemMargin = getResources().getDimensionPixelSize(R.dimen.table_item_margin);
50 | mItemPlaceHeight = getResources().getDimensionPixelSize(R.dimen.table_top_title_place);
51 | }
52 |
53 | private void initPaint() {
54 | mTextTopTitleColor = ContextCompat.getColor(getContext(), R.color.table_text_secondary_color);
55 | mTextNormal = getResources().getDimension(R.dimen.table_default_title_size);
56 |
57 | mPaintTextNormal = new Paint(Paint.ANTI_ALIAS_FLAG);
58 | mPaintTextNormal.setColor(mTextTopTitleColor);
59 | mPaintTextNormal.setTextSize(mTextNormal);
60 | }
61 |
62 | @Override
63 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
64 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
65 | int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
66 | mItemHeight = sizeHeight;
67 | setMeasuredDimension(column * mItemWidth + (column - 1) * mItemMargin, mItemHeight);
68 | }
69 |
70 | @Override
71 | protected void onDraw(Canvas canvas) {
72 | super.onDraw(canvas);
73 | drawItem(canvas);
74 | }
75 |
76 | private void drawItem(Canvas canvas) {
77 | for (int columnIndex = 0; columnIndex < column; columnIndex++) {
78 | String content = titles.get(columnIndex);
79 | Paint.FontMetrics fontMetrics = mPaintTextNormal.getFontMetrics();
80 | float fontHeight = fontMetrics.bottom - fontMetrics.top;
81 | float textWidth = mPaintTextNormal.measureText(content);
82 | float y = mItemPlaceHeight - (mItemPlaceHeight - fontHeight) / 2 - fontMetrics.bottom;
83 |
84 | float x = (mItemMargin + mItemWidth) * columnIndex + mItemWidth / 2 - textWidth / 2;
85 |
86 | canvas.drawText(content, x, y, mPaintTextNormal);
87 |
88 | }
89 | }
90 |
91 | public void updateTitles(ArrayList data) {
92 | titles.clear();
93 | titles.addAll(data);
94 | updateView();
95 | }
96 |
97 | private void updateView() {
98 | invalidate();
99 | column = titles.size();
100 | }
101 |
102 | public void setItemHeight(int height) {
103 | mItemHeight = height;
104 | invalidate();
105 | }
106 |
107 | public void setPlaceHeight(int height) {
108 | mItemPlaceHeight = height;
109 | invalidate();
110 | }
111 |
112 | public void setItemWidth(int width) {
113 | mItemWidth = width;
114 | invalidate();
115 | }
116 |
117 | public void setItemMargin(int margin) {
118 | mItemMargin = margin;
119 | invalidate();
120 | }
121 |
122 | public void setTextTopTitleColor(int color) {
123 | mTextTopTitleColor = color;
124 | mPaintTextNormal.setColor(mTextTopTitleColor);
125 | invalidate();
126 | }
127 |
128 | public void setPaintTextNormalSize(float size) {
129 | mTextNormal = size;
130 | mPaintTextNormal.setTextSize(mTextNormal);
131 | invalidate();
132 | }
133 |
134 | public void setUpAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
135 | if (attrs == null) return;
136 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrollTableView, defStyleAttr, 0);
137 | if (a == null) return;
138 |
139 | setItemHeight(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemHeight, mItemHeight));
140 | setItemWidth(a.getDimensionPixelSize(R.styleable.ScrollTableView_itemWidth, mItemWidth));
141 | setItemMargin(a.getDimensionPixelSize(R.styleable.ScrollTableView_dataMargin, mItemMargin));
142 | setPlaceHeight(a.getDimensionPixelSize(R.styleable.ScrollTableView_topPlaceHeight, mItemPlaceHeight));
143 | setTextTopTitleColor(a.getColor(R.styleable.ScrollTableView_textTopTitleColor, mTextTopTitleColor));
144 | setPaintTextNormalSize(a.getDimension(R.styleable.ScrollTableView_textTitleSize, mTextNormal));
145 |
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/java/com/loopeer/android/librarys/scrolltable/VerticalScrollView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.scrolltable;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.ScrollView;
6 |
7 | public class VerticalScrollView extends ScrollView implements IScroller{
8 |
9 | private IScroller scroller;
10 |
11 | public VerticalScrollView(Context context) {
12 | this(context, null);
13 | }
14 |
15 | public VerticalScrollView(Context context, AttributeSet attrs) {
16 | this(context, attrs, 0);
17 | }
18 |
19 | public VerticalScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
20 | super(context, attrs, defStyleAttr);
21 |
22 | }
23 |
24 | @Override
25 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
26 | super.onScrollChanged(l, t, oldl, oldt);
27 |
28 | if (scroller != null) {
29 | scroller.onScrollXY(l, t);
30 | }
31 | }
32 |
33 | public void setIScroller(IScroller scroller) {
34 | this.scroller = scroller;
35 | }
36 |
37 | @Override
38 | public void onScrollXY(int offsetX, int offsetY) {
39 | scrollTo(offsetX, offsetY);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/res/layout/list_item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/res/layout/view_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
32 |
33 |
37 |
38 |
43 |
44 |
48 |
49 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @android:color/white
5 | #2B2B2B
6 | #CBCBCB
7 | @android:color/white
8 | #D80C18
9 | #DCDCDC
10 |
11 | #727272
12 |
13 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16sp
4 | 14sp
5 |
6 | 80dp
7 | 36dp
8 | 12dp
9 | 48dp
10 |
11 | 30dp
12 | 80dp
13 | 2dp
14 | 4dp
15 | 8dp
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ScrollTable/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.loopeer.android.librarys.horizontalverticalscrollview"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:23.0.1'
25 | compile 'com.android.support:recyclerview-v7:23.0.1'
26 | compile project(':ScrollTable');
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/todou/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/loopeer/android/librarys/horizontalverticalscrollview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.horizontalverticalscrollview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/horizontalverticalscrollview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.horizontalverticalscrollview;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import com.loopeer.android.librarys.scrolltable.ScrollTableView;
7 |
8 | import java.util.ArrayList;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | private static final String[] topTitles = new String[] {"场地一", "场地二", "场地三", "场地四", "场地五", "场地六", "场地七", "场地八", "场地九", "场地十", "场地十一"};
13 |
14 | private ScrollTableView scrollTableView;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 |
21 | scrollTableView = (ScrollTableView) findViewById(R.id.scroll_table_view);
22 | ArrayList leftTitle = createLeftTitle();
23 | ArrayList topTitles = createTopTitles();
24 | scrollTableView.setDatas(createTopTitles(), createLeftTitle(), createContent(leftTitle.size(), topTitles.size()));
25 | }
26 |
27 | private ArrayList> createContent(int row, int column) {
28 | ArrayList> results = new ArrayList<>();
29 | for (int i = 0; i < row; i++) {
30 | ArrayList strings = new ArrayList<>();
31 | for (int j = 0; j < column; j++) {
32 | strings.add("$" + i + "" + j);
33 | }
34 | results.add(strings);
35 | }
36 | return results;
37 | }
38 |
39 | private ArrayList createTopTitles() {
40 | ArrayList results = new ArrayList<>();
41 | for (String string : topTitles) {
42 | results.add(string);
43 | }
44 | return results;
45 | }
46 |
47 | private ArrayList createLeftTitle() {
48 | ArrayList results = new ArrayList<>();
49 | for (int i = 9; i < 23; i++) {
50 | results.add(i + ":00");
51 | }
52 | return results;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HorizontalVerticalScrollView
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 25 07:36:50 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screenshot/screenshot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/screenshot/screenshot.gif
--------------------------------------------------------------------------------
/screenshot/screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/screenshot/screenshot1.png
--------------------------------------------------------------------------------
/screenshot/screenshot3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ScrollTableView/7025db51d219eb173f1cd1160df528f2e3a963f5/screenshot/screenshot3.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':ScrollTable'
2 |
--------------------------------------------------------------------------------