@@ -17,7 +17,9 @@ class Deck : ViewPager {
17
17
18
18
private val pageTransformer = CoverFlowTransformer ()
19
19
20
- constructor (context: Context ) : super (context)
20
+ constructor (context: Context ) : super (context) {
21
+ setPercentagePadding(context, DEFAULT_PERCENTAGE_PADDING )
22
+ }
21
23
22
24
constructor (context: Context , attributeSet: AttributeSet ) : super (context, attributeSet) {
23
25
val typedArray: TypedArray = context.obtainStyledAttributes(attributeSet, R .styleable.Deck )
@@ -30,6 +32,11 @@ class Deck : ViewPager {
30
32
initProperties(context, dipPaddingXmlInPixel.toFloat())
31
33
}
32
34
typedArray.recycle()
35
+
36
+ // set the default padding if no properties from XML
37
+ if (percentagePaddingXml == Integer .MAX_VALUE && dipPaddingXmlInPixel == Integer .MAX_VALUE ) {
38
+ setPercentagePadding(context, DEFAULT_PERCENTAGE_PADDING )
39
+ }
33
40
}
34
41
35
42
init {
@@ -40,13 +47,6 @@ class Deck : ViewPager {
40
47
setPageTransformer(true , pageTransformer)
41
48
}
42
49
43
- /* *
44
- * Set left and right padding with default value
45
- */
46
- fun setDefaultPadding (context : Context ) {
47
- setPercentagePadding(context, DEFAULT_PERCENTAGE_PADDING )
48
- }
49
-
50
50
/* *
51
51
* Set left and right padding based on percentage of the screen width
52
52
* If the percentage is more than 18, the left and right items height might not be consistent
0 commit comments