Commit 519be77c authored by yinjiacheng's avatar yinjiacheng

update 通用TopBar支持设置背景颜色、返回按钮图片、标题文字颜色

parent 14393818
......@@ -4,6 +4,7 @@ import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import com.yidian.bcommon.R
import com.yidian.bcommon.databinding.ViewCommonTopBarBinding
......@@ -48,14 +49,14 @@ class CommonTopBarView @JvmOverloads constructor(
if (it.isNotEmpty()) visibility = View.VISIBLE
viewBinding.tvAction.text = it
}
typeArray.getColor(R.styleable.CommonTopBarView_CommonTopBarView_bg_color, -1).let {
if (it != -1) viewBinding.root.setBackgroundColor(it)
typeArray.getColor(R.styleable.CommonTopBarView_CommonTopBarView_bg_color, ContextCompat.getColor(context, R.color.transparent)).let {
viewBinding.root.setBackgroundColor(it)
}
typeArray.getColor(R.styleable.CommonTopBarView_CommonTopBarView_title_text_color, -1).let {
if (it != -1) viewBinding.tvTitle.setTextColor(it)
typeArray.getColor(R.styleable.CommonTopBarView_CommonTopBarView_title_text_color, ContextCompat.getColor(context, R.color.color_333333)).let {
viewBinding.tvTitle.setTextColor(it)
}
typeArray.getResourceId(R.styleable.CommonTopBarView_CommonTopBarView_back_img, -1).let {
if (it != -1) viewBinding.ivBack.setImageResource(it)
typeArray.getResourceId(R.styleable.CommonTopBarView_CommonTopBarView_back_img, R.drawable.icon_back).let {
viewBinding.ivBack.setImageResource(it)
}
typeArray.recycle()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment