Skip to content

Commit 1841aca

Browse files
committed
first
0 parents  commit 1841aca

45 files changed

Lines changed: 1659 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/markdown-navigator.xml

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/markdown-navigator/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# ScrollTextView
2+
3+
### An Android Vertical Scrollable TextView;
4+
5+
### Android 垂直滚动的 TextView ;
6+
7+
![image](https://github.com/Dkaishu/ScrollTextView/blob/master/example.gif)
8+
9+
How to
10+
11+
#####To get a Git project into your build:
12+
13+
Step 1. Add the JitPack repository to your build file
14+
15+
Add it in your root build.gradle at the end of repositories:
16+
17+
allprojects {
18+
repositories {
19+
...
20+
maven { url 'https://jitpack.io' }
21+
}
22+
}
23+
Step 2. Add the dependency
24+
25+
dependencies {
26+
compile 'com.github.Dkaishu:ScrollTextView:V1.0.3'
27+
}
28+
29+
Step 3. Use it in your code
30+
31+
// .xml file:
32+
33+
<com.dkaishu.scrolltextview.ScrollTextView
34+
xmlns:scroll_text="http://schemas.android.com/apk/res-auto"
35+
android:id="@+id/stv_example"
36+
android:layout_width="match_parent"
37+
android:layout_height="30dp"
38+
android:layout_gravity="center_vertical"
39+
android:padding="5dp"
40+
scroll_text:ellipsis="false"
41+
scroll_text:singleLine="true"
42+
scroll_text:textColor="@android:color/black"
43+
scroll_text:textSize="14sp"
44+
/>
45+
46+
47+
48+
49+
//java file:
50+
51+
ScrollTextView stvExample = (ScrollTextView) findViewById(R.id.stv_example);
52+
53+
List<String> textList = new ArrayList<>();
54+
//note : clickListener 、scrollListener can be null ;
55+
List<ScrollTextView.OnScrollClickListener> clickListeners = new ArrayList<>();
56+
List<ScrollTextView.OnScrollListener> scrollListeners = new ArrayList<>();
57+
58+
textList.add("Be yourself, never give up. The adolescent girl from Tennessee is standing on the stage of a drama summer camp in upstate New York. It's a beautiful day. But the girl doesn't feel beautiful. She's not the leggy, glamorous Hollywood type.");
59+
textList.add("一名少女由田纳西州来到纽约北部,她站在戏剧夏令营的舞台上,虽然天气是那么好,她的心情却一点也不好。");
60+
61+
62+
clickListeners.add(new ScrollTextView.OnScrollClickListener() {
63+
@Override
64+
public void onClick() {
65+
Toast.makeText(MainActivity.this, "this is text one", Toast.LENGTH_SHORT).show();
66+
}
67+
});
68+
69+
clickListeners.add(new ScrollTextView.OnScrollClickListener() {
70+
@Override
71+
public void onClick() {
72+
Toast.makeText(MainActivity.this, "this is text two", Toast.LENGTH_SHORT).show();
73+
}
74+
});
75+
76+
77+
scrollListeners.add(new ScrollTextView.OnScrollListener() {
78+
@Override
79+
public void onScrollStart(List<ScrollTextView.TextInfo> passedTextInfos) {
80+
String text = "";
81+
for (ScrollTextView.TextInfo s : passedTextInfos) {
82+
text = text + s.getText();
83+
}
84+
Log.e(TAG, "" + text);
85+
}
86+
@Override
87+
public void onScrollEnd(List<ScrollTextView.TextInfo> incommingTextInfos) {
88+
String text = "";
89+
for (ScrollTextView.TextInfo s : incommingTextInfos) {
90+
text = text + s.getText();
91+
}
92+
Log.e(TAG, "" + text);
93+
}
94+
});
95+
96+
// stvExample.setScrollTime(500);
97+
// stvExample.setSpanTime(3000);
98+
// stvExample.setTextColor();
99+
// stvExample.setTextSize();
100+
stvExample.setTextContent(textList, clickListeners, scrollListeners);
101+
102+
And you may need this in your activity :
103+
104+
@Override
105+
protected void onRestart() {
106+
super.onRestart();
107+
stvExample.startTextScroll();
108+
}
109+
110+
@Override
111+
protected void onStop() {
112+
super.onStop();
113+
stvExample.stopTextScroll();
114+
}
115+
116+
That's it!

0 commit comments

Comments
 (0)