Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
Widget
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
Android Widget
Widget
Commits
c8b6782e
Commit
c8b6782e
authored
Aug 07, 2019
by
王韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[new] 修改readme
parent
255526fa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
9 deletions
+55
-9
activity_main.xml
app/src/main/res/layout/activity_main.xml
+6
-0
topar_nomal.png
img/topar_nomal.png
+0
-0
DpTools.kt
tools/src/main/java/com/qimai/android/tools/DpTools.kt
+1
-1
TopBarReadMe.MD
widgetlib/TopBarReadMe.MD
+39
-0
QmTopBar.kt
.../main/java/com/qimai/android/widgetlib/topbar/QmTopBar.kt
+8
-7
colors.xml
widgetlib/src/main/res/values/colors.xml
+1
-1
No files found.
app/src/main/res/layout/activity_main.xml
View file @
c8b6782e
...
@@ -11,6 +11,12 @@
...
@@ -11,6 +11,12 @@
<com.qimai.android.widgetlib.topbar.QmTopBar
<com.qimai.android.widgetlib.topbar.QmTopBar
android:id=
"@+id/toolbar"
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
app:title_color=
"@color/colorPrimary"
app:title_text_size=
"@dimen/QmTopBar_dp_18"
app:right_drawable_id=
"@drawable/more"
app:right_text=
"确定"
app:need_separator=
"true"
app:right_text_color=
"@color/colorAccent"
app:title_text=
"详情"
app:title_text=
"详情"
android:layout_height=
"45dp"
/>
android:layout_height=
"45dp"
/>
...
...
img/topar_nomal.png
0 → 100644
View file @
c8b6782e
15 KB
tools/src/main/java/com/qimai/android/tools/DpTools.kt
View file @
c8b6782e
...
@@ -3,7 +3,7 @@ package com.qimai.android.tools
...
@@ -3,7 +3,7 @@ package com.qimai.android.tools
import
android.content.Context
import
android.content.Context
fun
dipTopx
(
context
:
Context
,
dp
:
In
t
):
Int
{
fun
dipTopx
(
context
:
Context
,
dp
:
Floa
t
):
Int
{
val
scale
=
context
.
resources
.
displayMetrics
.
density
val
scale
=
context
.
resources
.
displayMetrics
.
density
return
(
dp
*
scale
+
0.5f
).
toInt
()
return
(
dp
*
scale
+
0.5f
).
toInt
()
}
}
...
...
widgetlib/TopBarReadMe.MD
View file @
c8b6782e
...
@@ -3,8 +3,47 @@
...
@@ -3,8 +3,47 @@
接入方法
接入方法
````
````
````
````
用法
```
<com.qimai.android.widgetlib.topbar.QmTopBar
android:id="@+id/toolbar"
android:layout_width="match_parent"
app:title_color="@color/colorPrimary"
app:title_text_size="@dimen/QmTopBar_dp_18"
app:right_drawable_id="@drawable/more"
app:right_text="确定"
app:need_separator="true"
app:right_text_color="@color/colorAccent"
app:title_text="详情"
android:layout_height="45dp"/>
///-----------------------------------------
// 是否需要分割线
<attr name="need_separator" format="boolean"/>
<attr name="separator_color" format="color"/>
<attr name="separator_height" format="dimension"/>
<!-- titlebar背景颜色-->
<attr name="bg_color" format="color"/>
// 返回按钮的图片
<attr name="left_back_drawable_id" format="reference"/>
// title 相关
<attr name="title_text_size" format="dimension"/>
<attr name="title_color" format="color"/>
<attr name="title_text" format="string"/>
// 右边按钮相关
<attr name="right_drawable_id" format="reference"/>
// 右边文案相关
<attr name="right_text" format="string"/>
<attr name="right_text_color" format="color"/>
<attr name="right_text_size" format="dimension"/>
<attr name="right_text_background" format="reference"/>
```
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/topbar/QmTopBar.kt
View file @
c8b6782e
...
@@ -180,7 +180,7 @@ class QmTopBar : Toolbar {
...
@@ -180,7 +180,7 @@ class QmTopBar : Toolbar {
leftImageViewParams
.
addRule
(
RelativeLayout
.
ALIGN_LEFT
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
ALIGN_LEFT
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
leftImageViewParams
.
leftMargin
=
dipTopx
(
context
,
16
)
leftImageViewParams
.
leftMargin
=
dipTopx
(
context
,
16
f
)
relativeLayout
.
addView
(
view
,
leftImageViewParams
)
relativeLayout
.
addView
(
view
,
leftImageViewParams
)
relativeLayout
.
removeView
(
leftImageView
)
relativeLayout
.
removeView
(
leftImageView
)
return
return
...
@@ -206,7 +206,7 @@ class QmTopBar : Toolbar {
...
@@ -206,7 +206,7 @@ class QmTopBar : Toolbar {
mRightImg
.
setImageResource
(
qmTopBarRightDrawable
)
mRightImg
.
setImageResource
(
qmTopBarRightDrawable
)
rightImgParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightImgParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightImgParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
)
rightImgParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
)
rightImgParams
.
rightMargin
=
dipTopx
(
context
,
16
)
rightImgParams
.
rightMargin
=
dipTopx
(
context
,
16
f
)
relativeLayout
.
addView
(
mRightImg
,
rightImgParams
)
relativeLayout
.
addView
(
mRightImg
,
rightImgParams
)
registerRightImgListener
()
registerRightImgListener
()
}
}
...
@@ -232,7 +232,7 @@ class QmTopBar : Toolbar {
...
@@ -232,7 +232,7 @@ class QmTopBar : Toolbar {
rightTextParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightTextParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
}
else
{
}
else
{
rightTextParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightTextParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightTextParams
.
marginEnd
=
dipTopx
(
context
,
16
)
rightTextParams
.
marginEnd
=
dipTopx
(
context
,
16
f
)
rightTextParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
)
rightTextParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
)
}
}
mRightTextView
.
setPadding
(
15
,
5
,
15
,
5
)
mRightTextView
.
setPadding
(
15
,
5
,
15
,
5
)
...
@@ -288,7 +288,8 @@ class QmTopBar : Toolbar {
...
@@ -288,7 +288,8 @@ class QmTopBar : Toolbar {
// 下划线
// 下划线
if
(
qmTopBarNeedSeparator
&&
!
::
lineView
.
isInitialized
)
{
if
(
qmTopBarNeedSeparator
&&
!
::
lineView
.
isInitialized
)
{
lineView
=
View
(
context
)
lineView
=
View
(
context
)
val
lineParams
=
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
dipTopx
(
context
,
1
))
val
lineParams
=
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
dipTopx
(
context
,
0.5f
))
lineView
.
setBackgroundColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
QmTopBar_color_999999
))
lineView
.
setBackgroundColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
QmTopBar_color_999999
))
lineParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_BOTTOM
)
lineParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_BOTTOM
)
relativeLayout
.
addView
(
lineView
,
lineParams
)
relativeLayout
.
addView
(
lineView
,
lineParams
)
...
@@ -306,13 +307,13 @@ class QmTopBar : Toolbar {
...
@@ -306,13 +307,13 @@ class QmTopBar : Toolbar {
leftImageView
.
setImageDrawable
(
ContextCompat
.
getDrawable
(
context
,
qmTopBarLeftDrawable
))
leftImageView
.
setImageDrawable
(
ContextCompat
.
getDrawable
(
context
,
qmTopBarLeftDrawable
))
leftImageView
.
id
=
View
.
generateViewId
()
leftImageView
.
id
=
View
.
generateViewId
()
val
leftImageViewParams
=
RelativeLayout
.
LayoutParams
(
val
leftImageViewParams
=
RelativeLayout
.
LayoutParams
(
dipTopx
(
context
,
16
),
dipTopx
(
context
,
16
f
),
dipTopx
(
context
,
16
)
dipTopx
(
context
,
16
f
)
)
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
ALIGN_LEFT
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
ALIGN_LEFT
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
leftImageViewParams
.
leftMargin
=
dipTopx
(
context
,
16
)
leftImageViewParams
.
leftMargin
=
dipTopx
(
context
,
16
f
)
relativeLayout
.
addView
(
leftImageView
,
leftImageViewParams
)
relativeLayout
.
addView
(
leftImageView
,
leftImageViewParams
)
}
}
...
...
widgetlib/src/main/res/values/colors.xml
View file @
c8b6782e
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<color
name=
"QmTopBar_color_999999"
>
#
999999
</color>
<color
name=
"QmTopBar_color_999999"
>
#
C0BEBE
</color>
<color
name=
"QmTopBar_color_FFFFFFF"
>
#FFFFFF
</color>
<color
name=
"QmTopBar_color_FFFFFFF"
>
#FFFFFF
</color>
<color
name=
"QmTopBar_color_3333333"
>
#333333
</color>
<color
name=
"QmTopBar_color_3333333"
>
#333333
</color>
<color
name=
"QmTopBar_color_000000"
>
#000000
</color>
<color
name=
"QmTopBar_color_000000"
>
#000000
</color>
...
...
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