diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/ViewUtils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/views/ViewUtils.kt | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/ViewUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/ViewUtils.kt index 513287ef..01a49f7e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/ViewUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/ViewUtils.kt @@ -1,14 +1,30 @@ package com.pitchedapps.frost.views +import android.content.res.ColorStateList +import android.graphics.PorterDuff +import android.support.annotation.ColorInt +import android.support.annotation.ColorRes +import android.support.v4.content.ContextCompat import android.view.View import android.view.ViewGroup +import android.widget.ProgressBar + /** * Created by Allan Wang on 2017-05-31. */ fun View.matchParent() { - with (layoutParams) { + with(layoutParams) { height = ViewGroup.LayoutParams.MATCH_PARENT width = ViewGroup.LayoutParams.MATCH_PARENT } +} + +fun ProgressBar.tintRes(@ColorRes id: Int) = tint(ContextCompat.getColor(context, id)) + +fun ProgressBar.tint(@ColorInt color: Int) { + val sl = ColorStateList.valueOf(color) + progressTintList = sl + secondaryProgressTintList = sl + indeterminateTintList = sl }
\ No newline at end of file |