Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 6548228

Browse files
committed
Added initial state
1 parent df3e3d2 commit 6548228

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ public class ScrollingImageView extends View {
3535
public ScrollingImageView(Context context, AttributeSet attrs) {
3636
super(context, attrs);
3737
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ParallaxView, 0, 0);
38+
int initialState = 0;
3839
try {
40+
initialState = ta.getInt(R.styleable.ParallaxView_initialState, 0);
3941
speed = ta.getDimension(R.styleable.ParallaxView_speed, 10);
4042
int sceneLength = ta.getInt(R.styleable.ParallaxView_sceneLength, 1000);
4143
final int randomnessResourceId = ta.getResourceId(R.styleable.ParallaxView_randomness, 0);
@@ -86,7 +88,10 @@ public ScrollingImageView(Context context, AttributeSet attrs) {
8688
} finally {
8789
ta.recycle();
8890
}
89-
start();
91+
92+
if (initialState == 0) {
93+
start();
94+
}
9095
}
9196

9297
@Override

library/src/main/res/values/attr.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
<attr name="src" format="reference" />
66
<attr name="sceneLength" format="integer" />
77
<attr name="randomness" format="reference" />
8+
<attr name="initialState" format="enum">
9+
<enum name="started" value="0" />
10+
<enum name="stopped" value="1" />
11+
</attr>
812
</declare-styleable>
913
</resources>

0 commit comments

Comments
 (0)