Skip to content

Commit

Permalink
fixed background color bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ertugrulkaragoz committed Apr 1, 2021
1 parent 181751f commit e981341
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/src/main/java/me/ertugrul/lib/SuperBottomBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SuperBottomBar @JvmOverloads constructor(
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {

//Attributes
private var menu: Menu? = null

@ColorInt
Expand Down Expand Up @@ -46,16 +47,19 @@ class SuperBottomBar @JvmOverloads constructor(

private var activeItem = DEFAULT_ACTIVE_ITEM

private var currentScalePercent = DEFAULT_START_SCALE

//Dynamic variables
private var layoutWidth: Float = 0f
private var layoutHeight: Float = 0f

private var itemWidth: Float = 0f
private var itemHeight: Float = 0f

private var currentItemPosition: Int = 0
private var currentItemColor = activeColor
private var currentScalePercent = DEFAULT_START_SCALE
private var currentItemColor = passiveColor

//Paints
private val paintBackground = Paint().apply {
isAntiAlias = true
style = Paint.Style.FILL
Expand All @@ -71,6 +75,7 @@ class SuperBottomBar @JvmOverloads constructor(
isFakeBoldText = true
}

//Listeners
private var bottomBarItemList = mutableListOf<BottomBarItem>()

private var onItemSelectedListener: OnItemSelectedListener? = null
Expand All @@ -91,7 +96,7 @@ class SuperBottomBar @JvmOverloads constructor(
)
try {
tabBackgroundColor = typedArray.getColor(
R.styleable.SuperBottomBar_activeColor,
R.styleable.SuperBottomBar_backgroundColor,
Color.parseColor(DEFAULT_BACKGROUND_COLOR)
)
activeColor = typedArray.getColor(
Expand All @@ -102,6 +107,7 @@ class SuperBottomBar @JvmOverloads constructor(
R.styleable.SuperBottomBar_passiveColor,
Color.parseColor(DEFAULT_PASSIVE_COLOR)
)
currentItemColor = passiveColor
pressedColor = typedArray.getColor(
R.styleable.SuperBottomBar_pressedColor,
Color.parseColor(DEFAULT_PRESSED_COLOR)
Expand Down Expand Up @@ -165,6 +171,7 @@ class SuperBottomBar @JvmOverloads constructor(
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)

paintBackground.color = tabBackgroundColor
canvas.drawRect(
0f, 0f,
width.toFloat(),
Expand Down

0 comments on commit e981341

Please sign in to comment.