Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-picker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-picker
Commits
f9338d08
Commit
f9338d08
authored
Oct 20, 2016
by
xwenliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: android splitters color
parent
e707f315
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
android/src/main/java/com/beefe/picker/view/LoopView.java
android/src/main/java/com/beefe/picker/view/LoopView.java
+26
-7
package.json
package.json
+1
-1
No files found.
android/src/main/java/com/beefe/picker/view/LoopView.java
View file @
f9338d08
...
@@ -4,6 +4,7 @@ import android.content.Context;
...
@@ -4,6 +4,7 @@ import android.content.Context;
import
android.graphics.Canvas
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.Paint
;
import
android.graphics.Rect
;
import
android.graphics.Rect
;
import
android.graphics.RectF
;
import
android.graphics.Typeface
;
import
android.graphics.Typeface
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
...
@@ -17,6 +18,11 @@ import java.util.concurrent.ScheduledExecutorService;
...
@@ -17,6 +18,11 @@ import java.util.concurrent.ScheduledExecutorService;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
* Edited by shexiaoheng on 2016/10/20
* 1. Added method getY
* 2. Changed line color 0xffc5c5c5 -> 0xffb8bbc2
*/
public
class
LoopView
extends
View
{
public
class
LoopView
extends
View
{
private
float
scaleX
=
1.05
F
;
private
float
scaleX
=
1.05
F
;
...
@@ -106,7 +112,8 @@ public class LoopView extends View {
...
@@ -106,7 +112,8 @@ public class LoopView extends View {
textSize
=
0
;
textSize
=
0
;
colorGray
=
0xffafafaf
;
colorGray
=
0xffafafaf
;
colorBlack
=
0xff313131
;
colorBlack
=
0xff313131
;
colorLightGray
=
0xffc5c5c5
;
colorLightGray
=
0xffb8bbc2
;
// colorLightGray = 0xffc5c5c5;
totalScrollY
=
0
;
totalScrollY
=
0
;
initPosition
=
-
1
;
initPosition
=
-
1
;
...
@@ -338,32 +345,32 @@ public class LoopView extends View {
...
@@ -338,32 +345,32 @@ public class LoopView extends View {
// 条目经过第一条线
// 条目经过第一条线
canvas
.
save
();
canvas
.
save
();
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
firstLineY
-
translateY
);
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
firstLineY
-
translateY
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintOuterText
),
maxTextHeight
,
paintOuterText
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintOuterText
),
getY
(
paintOuterText
)
,
paintOuterText
);
canvas
.
restore
();
canvas
.
restore
();
canvas
.
save
();
canvas
.
save
();
canvas
.
clipRect
(
0
,
firstLineY
-
translateY
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
clipRect
(
0
,
firstLineY
-
translateY
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
drawText
(
text
,
getX
(
text
,
paintCenterText
),
maxTextHeight
,
paintCenterText
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintCenterText
),
getY
(
paintCenterText
)
,
paintCenterText
);
canvas
.
restore
();
canvas
.
restore
();
}
else
if
(
translateY
<=
secondLineY
&&
maxTextHeight
+
translateY
>=
secondLineY
)
{
}
else
if
(
translateY
<=
secondLineY
&&
maxTextHeight
+
translateY
>=
secondLineY
)
{
// 条目经过第二条线
// 条目经过第二条线
canvas
.
save
();
canvas
.
save
();
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
secondLineY
-
translateY
);
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
secondLineY
-
translateY
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintCenterText
),
maxTextHeight
,
paintCenterText
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintCenterText
),
getY
(
paintCenterText
)
,
paintCenterText
);
canvas
.
restore
();
canvas
.
restore
();
canvas
.
save
();
canvas
.
save
();
canvas
.
clipRect
(
0
,
secondLineY
-
translateY
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
clipRect
(
0
,
secondLineY
-
translateY
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
drawText
(
text
,
getX
(
text
,
paintOuterText
),
maxTextHeight
,
paintOuterText
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintOuterText
),
getY
(
paintOuterText
)
,
paintOuterText
);
canvas
.
restore
();
canvas
.
restore
();
}
else
if
(
translateY
>=
firstLineY
&&
maxTextHeight
+
translateY
<=
secondLineY
)
{
}
else
if
(
translateY
>=
firstLineY
&&
maxTextHeight
+
translateY
<=
secondLineY
)
{
// 中间条目
// 中间条目
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
drawText
(
text
,
getX
(
text
,
paintCenterText
),
maxTextHeight
,
paintCenterText
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintCenterText
),
getY
(
paintCenterText
)
,
paintCenterText
);
selectedItem
=
text
;
selectedItem
=
text
;
selectedIndex
=
items
.
indexOf
(
text
);
selectedIndex
=
items
.
indexOf
(
text
);
}
else
{
}
else
{
// 其他条目
// 其他条目
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
clipRect
(
0
,
0
,
getWidth
(),
(
int
)
(
itemHeight
));
canvas
.
drawText
(
text
,
getX
(
text
,
paintOuterText
),
maxTextHeight
,
paintOuterText
);
canvas
.
drawText
(
text
,
getX
(
text
,
paintOuterText
),
getY
(
paintOuterText
)
,
paintOuterText
);
}
}
canvas
.
restore
();
canvas
.
restore
();
}
}
...
@@ -376,6 +383,18 @@ public class LoopView extends View {
...
@@ -376,6 +383,18 @@ public class LoopView extends View {
return
(
getWidth
()
-
tempRect
.
width
()
*
scaleX
)
/
2
;
return
(
getWidth
()
-
tempRect
.
width
()
*
scaleX
)
/
2
;
}
}
/**
* Added by shexiaoheng
* 让字体垂直方向居中
* */
private
float
getY
(
Paint
paint
)
{
Rect
rect
=
new
Rect
(
0
,
0
,
getWidth
(),
maxTextHeight
);
RectF
bounds
=
new
RectF
(
rect
);
bounds
.
bottom
=
paint
.
descent
()
-
paint
.
ascent
();
bounds
.
top
+=
(
rect
.
height
()
-
bounds
.
bottom
)
/
2.0f
;
return
bounds
.
top
-
paint
.
ascent
();
}
@Override
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
...
...
package.json
View file @
f9338d08
{
{
"name"
:
"react-native-picker"
,
"name"
:
"react-native-picker"
,
"version"
:
"4.0.
6
"
,
"version"
:
"4.0.
7
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment