fixed follow button color under Android 5.0

This commit is contained in:
Mariotaku Lee 2017-04-11 21:01:25 +08:00
parent 94560df05f
commit 56df1bf145
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 11 additions and 3 deletions

View File

@ -29,6 +29,7 @@ import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.graphics.Outline
import android.graphics.PorterDuff
import android.graphics.Rect
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
@ -1579,9 +1580,11 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
}
private fun setFollowEditButton(@DrawableRes icon: Int, @ColorRes color: Int, @StringRes label: Int) {
followContainer.follow.setImageResource(icon)
ViewCompat.setBackgroundTintList(followContainer.follow, ContextCompat.getColorStateList(context, color))
followContainer.follow.contentDescription = getString(label)
val followButton = followContainer.follow
followButton.setImageResource(icon)
ViewCompat.setBackgroundTintMode(followButton, PorterDuff.Mode.SRC_ATOP)
ViewCompat.setBackgroundTintList(followButton, ContextCompat.getColorStateList(context, color))
followButton.contentDescription = getString(label)
}
private class ActionBarDrawable(shadow: Drawable) : LayerDrawable(arrayOf(shadow, ActionBarColorDrawable.create(true))) {

View File

@ -94,6 +94,11 @@ class IconActionButton(
updateColorFilter()
}
override fun setSupportBackgroundTintList(tint: ColorStateList?) {
super.setSupportBackgroundTintList(tint)
updateColorFilter()
}
override fun isPostApplyTheme(): Boolean {
return false
}