Commit 74820d6d authored by yinjiacheng's avatar yinjiacheng

update 扩展通用TopBar属性

parent 6d7ab05e
......@@ -48,6 +48,15 @@ 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_title_text_color, -1).let {
if (it != -1) viewBinding.tvTitle.setTextColor(it)
}
typeArray.getResourceId(R.styleable.CommonTopBarView_CommonTopBarView_back_img, -1).let {
if (it != -1) viewBinding.ivBack.setImageResource(it)
}
typeArray.recycle()
viewBinding.ivBack.setOnClickListener(this)
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CommonTopBarView">
<!--标题文字-->
<attr name="CommonTopBarView_title_text" format="string" />
<!--操作按钮文字-->
<attr name="CommonTopBarView_action_text" format="string" />
<!--整体背景色-->
<attr name="CommonTopBarView_bg_color" format="color" />
<!--标题文字颜色-->
<attr name="CommonTopBarView_title_text_color" format="color" />
<!--返回按钮图标-->
<attr name="CommonTopBarView_back_img" format="reference" />
</declare-styleable>
<declare-styleable name="CommonEmptyPageView">
<attr name="CommonEmptyPageView_place_holder_img" format="reference" />
......
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