Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
ebe280ae
Commit
ebe280ae
authored
Aug 27, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 通用TopBar属性支持代码设置
parent
5cba4e51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
CommonTopBarView.kt
...c/main/java/com/yidian/bcommon/widget/CommonTopBarView.kt
+33
-2
No files found.
CommonLib/BCommon/src/main/java/com/yidian/bcommon/widget/CommonTopBarView.kt
View file @
ebe280ae
...
@@ -6,6 +6,8 @@ import android.util.AttributeSet
...
@@ -6,6 +6,8 @@ import android.util.AttributeSet
import
android.view.View
import
android.view.View
import
android.view.ViewTreeObserver
import
android.view.ViewTreeObserver
import
android.view.WindowManager
import
android.view.WindowManager
import
androidx.annotation.ColorInt
import
androidx.annotation.DrawableRes
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
...
@@ -66,7 +68,7 @@ class CommonTopBarView @JvmOverloads constructor(
...
@@ -66,7 +68,7 @@ class CommonTopBarView @JvmOverloads constructor(
viewBinding
.
tvAction
.
isVisible
=
action
.
isNotEmpty
()
viewBinding
.
tvAction
.
isVisible
=
action
.
isNotEmpty
()
viewBinding
.
tvAction
.
text
=
action
viewBinding
.
tvAction
.
text
=
action
// 设置背景色
// 设置背景色
viewBinding
.
root
.
setBackgroundColor
(
setBackgroundColor
(
typeArray
.
getColor
(
typeArray
.
getColor
(
R
.
styleable
.
CommonTopBarView_CommonTopBarView_bg_color
,
R
.
styleable
.
CommonTopBarView_CommonTopBarView_bg_color
,
ContextCompat
.
getColor
(
context
,
R
.
color
.
transparent
)
ContextCompat
.
getColor
(
context
,
R
.
color
.
transparent
)
...
@@ -96,12 +98,41 @@ class CommonTopBarView @JvmOverloads constructor(
...
@@ -96,12 +98,41 @@ class CommonTopBarView @JvmOverloads constructor(
}
}
/**
/**
* 设置
title
* 设置
标题
*/
*/
fun
setTitle
(
title
:
String
)
{
fun
setTitle
(
title
:
String
)
{
viewBinding
.
tvTitle
.
text
=
title
viewBinding
.
tvTitle
.
text
=
title
}
}
/**
* 设置标题文字颜色
*/
fun
setTitleTextColor
(
@ColorInt
color
:
Int
)
{
viewBinding
.
tvTitle
.
setTextColor
(
color
)
}
/**
* 设置背景色
*/
fun
setRootBackgroundColor
(
@ColorInt
color
:
Int
)
{
setBackgroundColor
(
color
)
}
/**
* 设置返回按钮图标
*/
fun
setBackImageResource
(
@DrawableRes
resource
:
Int
)
{
viewBinding
.
ivBack
.
setImageResource
(
resource
)
}
/**
* 设置横向内边距
* @param padding 单位: px
*/
fun
setRootHorizontalPadding
(
padding
:
Int
)
{
setPadding
(
padding
,
0
,
padding
,
0
)
}
/**
/**
* 设置返回按钮是否可见
* 设置返回按钮是否可见
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment