-
Notifications
You must be signed in to change notification settings - Fork 0
/
NestedSpinnerStyle.kt
76 lines (65 loc) · 2.49 KB
/
NestedSpinnerStyle.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.nickwang.nestedspinner
import android.content.Context
import android.content.res.TypedArray
import android.graphics.Color
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
/**
* @author nickwang
* Created 12/08/21
*/
class NestedSpinnerStyle(context: Context, typedArray: TypedArray) {
@ColorInt
var popupBackgroundColour: Int = 0
var initExpanded: Boolean = false
var groupItemHeight: Int = 0
@ColorInt
var groupBackgroundColour: Int = 0
@ColorInt
var groupTextColour: Int = 0
var groupTextSize: Int = 0
var subItemHeight: Int = 0
@ColorInt
var subBackgroundColour: Int = 0
@ColorInt
var subTextColour: Int = 0
var subTextSize: Int = 0
init {
popupBackgroundColour = typedArray.getColor(
R.styleable.NestedSpinnerView_popupBackgroundColour,
ContextCompat.getColor(context, R.color.black)
)
initExpanded = typedArray.getBoolean(R.styleable.NestedSpinnerView_initExpanded, false)
groupItemHeight = typedArray.getDimensionPixelSize(
R.styleable.NestedSpinnerView_groupItemHeight,
context.resources.getDimensionPixelSize(R.dimen.group_height)
)
groupBackgroundColour = typedArray.getColor(
R.styleable.NestedSpinnerView_groupBackgroundColour,
ContextCompat.getColor(context, R.color.background_dark)
)
groupTextColour =
typedArray.getColor(R.styleable.NestedSpinnerView_groupTextColour, Color.WHITE)
groupTextSize =
typedArray.getDimensionPixelSize(
R.styleable.NestedSpinnerView_groupTextSize,
context.resources.getDimensionPixelSize(R.dimen.group_text_size)
)
subItemHeight =
typedArray.getDimensionPixelSize(
R.styleable.NestedSpinnerView_subItemHeight,
context.resources.getDimensionPixelSize(R.dimen.sub_height)
)
subBackgroundColour = typedArray.getColor(
R.styleable.NestedSpinnerView_subBackgroundColour,
ContextCompat.getColor(context, R.color.background_dark)
)
subTextColour =
typedArray.getColor(R.styleable.NestedSpinnerView_subTextColour, Color.WHITE)
subTextSize =
typedArray.getDimensionPixelSize(
R.styleable.NestedSpinnerView_subTextSize,
context.resources.getDimensionPixelSize(R.dimen.sub_text_size)
)
}
}