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
d7e5749a
Commit
d7e5749a
authored
Sep 03, 2019
by
王韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[new] 完善功能
parent
ccd1e473
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
258 additions
and
44 deletions
+258
-44
build.gradle
app/build.gradle
+1
-0
TipActivity.kt
app/src/main/java/com/qimai/android/widget/TipActivity.kt
+105
-0
TopBarActivity.kt
app/src/main/java/com/qimai/android/widget/TopBarActivity.kt
+21
-4
activity_tip.xml
app/src/main/res/layout/activity_tip.xml
+31
-9
activity_top_bar.xml
app/src/main/res/layout/activity_top_bar.xml
+5
-1
goodmanager_pop_item.xml
app/src/main/res/layout/goodmanager_pop_item.xml
+18
-0
goodmanager_rightview_titlebar.xml
app/src/main/res/layout/goodmanager_rightview_titlebar.xml
+20
-0
styles.xml
app/src/main/res/values/styles.xml
+6
-0
QmTipOverlayDrawable.kt
...com/qimai/android/widgetlib/popup/QmTipOverlayDrawable.kt
+15
-7
QmToolTip.kt
.../main/java/com/qimai/android/widgetlib/popup/QmToolTip.kt
+31
-18
QmTopBar.kt
.../main/java/com/qimai/android/widgetlib/topbar/QmTopBar.kt
+1
-1
styles.xml
widgetlib/src/main/res/values/styles.xml
+4
-4
No files found.
app/build.gradle
View file @
d7e5749a
...
@@ -34,4 +34,5 @@ dependencies {
...
@@ -34,4 +34,5 @@ dependencies {
implementation
project
(
path:
':widgetlib'
)
implementation
project
(
path:
':widgetlib'
)
// implementation 'com.qmai.android.sdk:widgetlib:1.1.2-SNAPSHOT'
// implementation 'com.qmai.android.sdk:widgetlib:1.1.2-SNAPSHOT'
implementation
project
(
path:
':tools'
)
implementation
project
(
path:
':tools'
)
implementation
'androidx.recyclerview:recyclerview:1.0.0'
}
}
app/src/main/java/com/qimai/android/widget/TipActivity.kt
View file @
d7e5749a
...
@@ -3,16 +3,30 @@ package com.qimai.android.widget
...
@@ -3,16 +3,30 @@ package com.qimai.android.widget
import
android.os.Bundle
import
android.os.Bundle
import
android.view.Gravity
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.Button
import
android.widget.LinearLayout
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.qimai.android.widgetlib.popup.QmToolTip
import
com.qimai.android.widgetlib.popup.QmToolTip
import
com.qimai.android.widgetlib.topbar.QmTopBar
class
TipActivity
:
AppCompatActivity
()
{
class
TipActivity
:
AppCompatActivity
()
{
lateinit
var
mPop
:
QmToolTip
lateinit
var
topbar
:
QmTopBar
var
items
=
mutableListOf
(
"堂食"
,
"外卖"
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_tip
)
setContentView
(
R
.
layout
.
activity_tip
)
topbar
=
findViewById
(
R
.
id
.
topBar
)
customTopBar
()
findViewById
<
Button
>(
R
.
id
.
top
).
setOnClickListener
{
findViewById
<
Button
>(
R
.
id
.
top
).
setOnClickListener
{
val
view
=
LayoutInflater
.
from
(
TipActivity
@
this
).
inflate
(
R
.
layout
.
tip
,
null
)
val
view
=
LayoutInflater
.
from
(
TipActivity
@
this
).
inflate
(
R
.
layout
.
tip
,
null
)
...
@@ -36,5 +50,96 @@ class TipActivity : AppCompatActivity() {
...
@@ -36,5 +50,96 @@ class TipActivity : AppCompatActivity() {
.
build
().
show
()
.
build
().
show
()
}
}
findViewById
<
Button
>(
R
.
id
.
topnorrow
).
setOnClickListener
{
val
view
=
LayoutInflater
.
from
(
TipActivity
@
this
).
inflate
(
R
.
layout
.
tip
,
null
)
QmToolTip
.
Builder
()
.
withAttachedView
(
findViewById
(
R
.
id
.
topnorrow
))
.
withContentView
(
view
)
.
withArrowShow
(
false
)
.
withGravity
(
Gravity
.
TOP
)
.
build
().
show
()
}
findViewById
<
Button
>(
R
.
id
.
bottomnoArrow
).
setOnClickListener
{
val
view
=
LayoutInflater
.
from
(
TipActivity
@
this
).
inflate
(
R
.
layout
.
tip
,
null
)
QmToolTip
.
Builder
()
.
withAttachedView
(
findViewById
<
Button
>(
R
.
id
.
bottomnoArrow
))
.
withContentView
(
view
)
.
withArrowShow
(
false
)
.
withGravity
(
Gravity
.
BOTTOM
)
.
build
().
show
()
}
}
private
class
PopListAdapter
(
var
datas
:
MutableList
<
String
>,
var
itemClick
:
(
position
:
Int
)
->
Unit
)
:
RecyclerView
.
Adapter
<
PopListAdapter
.
PopListHolder
>()
{
private
var
currentChoosePositon
=
0
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
PopListHolder
{
return
PopListHolder
(
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
goodmanager_pop_item
,
parent
,
false
)
)
}
override
fun
getItemCount
():
Int
=
datas
.
size
override
fun
onBindViewHolder
(
holder
:
PopListHolder
,
position
:
Int
)
{
holder
.
content
.
text
=
datas
[
position
]
holder
.
container
.
setOnClickListener
{
currentChoosePositon
=
position
itemClick
.
invoke
(
position
)
}
holder
.
container
.
isSelected
=
position
==
currentChoosePositon
}
class
PopListHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
var
content
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
content
)
var
container
:
LinearLayout
=
itemView
.
findViewById
(
R
.
id
.
container
)
}
}
private
fun
customTopBar
()
{
val
topRight
=
layoutInflater
.
inflate
(
R
.
layout
.
goodmanager_rightview_titlebar
,
topbar
,
false
)
val
rightText
=
topRight
.
findViewById
<
TextView
>(
R
.
id
.
rightText
)
rightText
.
text
=
"堂食"
topbar
.
customRightView
(
topRight
,
null
)
val
recyclerView
=
RecyclerView
(
this
)
recyclerView
.
layoutParams
=
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
recyclerView
.
layoutManager
=
LinearLayoutManager
(
this
)
recyclerView
.
adapter
=
PopListAdapter
(
items
)
{
mPop
.
dismiss
()
}
topRight
.
setOnClickListener
{
if
(!
GoodsManagerActivity
@
this
::
mPop
.
isInitialized
)
{
GoodsManagerActivity
@
this
.
mPop
=
QmToolTip
.
Builder
()
.
withGravity
(
Gravity
.
BOTTOM
)
.
withAttachedView
(
topRight
)
.
withDefaultOverlayStyle
(
R
.
style
.
tangshi
)
.
withContentView
(
recyclerView
)
.
withArrowShow
(
true
)
.
withArrowWeight
(
0.5f
)
.
build
()
}
mPop
.
show
()
}
}
}
}
}
app/src/main/java/com/qimai/android/widget/TopBarActivity.kt
View file @
d7e5749a
package
com.qimai.android.widget
package
com.qimai.android.widget
import
android.graphics.Color
import
android.graphics.Color
import
androidx.appcompat.app.AppCompatActivity
import
android.os.Bundle
import
android.os.Bundle
import
android.widget.Button
import
android.widget.Button
import
android.widget.TextView
import
android.widget.TextView
import
android.widget.Toast
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
com.qimai.android.widgetlib.topbar.QmTopBar
import
com.qimai.android.widgetlib.topbar.QmTopBar
...
@@ -15,6 +15,7 @@ class TopBarActivity : AppCompatActivity() {
...
@@ -15,6 +15,7 @@ class TopBarActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_top_bar
)
setContentView
(
R
.
layout
.
activity_top_bar
)
val
toolbar
=
findViewById
<
QmTopBar
>(
R
.
id
.
toolbar
)
val
toolbar
=
findViewById
<
QmTopBar
>(
R
.
id
.
toolbar
)
val
topbar2
=
findViewById
<
QmTopBar
>(
R
.
id
.
topbar2
)
setSupportActionBar
(
toolbar
)
setSupportActionBar
(
toolbar
)
supportActionBar
?.
setDisplayShowCustomEnabled
(
false
)
supportActionBar
?.
setDisplayShowCustomEnabled
(
false
)
toolbar
.
registerViewClickListener
{
toolbar
.
registerViewClickListener
{
...
@@ -42,15 +43,22 @@ class TopBarActivity : AppCompatActivity() {
...
@@ -42,15 +43,22 @@ class TopBarActivity : AppCompatActivity() {
findViewById
<
Button
>(
R
.
id
.
leftTextview
).
setOnClickListener
{
findViewById
<
Button
>(
R
.
id
.
leftTextview
).
setOnClickListener
{
toolbar
.
rightTextProperty
=
toolbar
.
rightTextProperty
.
apply
{
toolbar
.
rightTextProperty
=
toolbar
.
rightTextProperty
.
apply
{
text
=
"确定"
text
=
"确定"
textColor
=
ContextCompat
.
getColor
(
this
@TopBarActivity
,
R
.
color
.
abc_btn_colored_borderless_text_material
)
textColor
=
ContextCompat
.
getColor
(
textBackground
=
ContextCompat
.
getDrawable
(
this
@TopBarActivity
,
R
.
drawable
.
btn_shape
)
this
@TopBarActivity
,
R
.
color
.
abc_btn_colored_borderless_text_material
)
textBackground
=
ContextCompat
.
getDrawable
(
this
@TopBarActivity
,
R
.
drawable
.
btn_shape
)
}
}
}
}
findViewById
<
Button
>(
R
.
id
.
center
).
setOnClickListener
{
findViewById
<
Button
>(
R
.
id
.
center
).
setOnClickListener
{
toolbar
.
centerTextProperty
=
toolbar
.
centerTextProperty
.
apply
{
toolbar
.
centerTextProperty
=
toolbar
.
centerTextProperty
.
apply
{
text
=
"修改"
text
=
"修改"
textColor
=
ContextCompat
.
getColor
(
this
@TopBarActivity
,
R
.
color
.
abc_btn_colored_borderless_text_material
)
textColor
=
ContextCompat
.
getColor
(
this
@TopBarActivity
,
R
.
color
.
abc_btn_colored_borderless_text_material
)
}
}
}
}
...
@@ -74,5 +82,14 @@ class TopBarActivity : AppCompatActivity() {
...
@@ -74,5 +82,14 @@ class TopBarActivity : AppCompatActivity() {
toolbar
.
customRightView
(
text
,
null
)
toolbar
.
customRightView
(
text
,
null
)
}
}
val
rightView
=
layoutInflater
.
inflate
(
R
.
layout
.
goodmanager_rightview_titlebar
,
topbar2
,
false
)
val
rightText
=
rightView
.
findViewById
<
TextView
>(
R
.
id
.
rightText
)
rightText
.
text
=
"堂食"
topbar2
.
customRightView
(
rightView
,
null
)
}
}
}
}
app/src/main/res/layout/activity_tip.xml
View file @
d7e5749a
...
@@ -3,10 +3,18 @@
...
@@ -3,10 +3,18 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:background=
"#E9DFE0"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#E9DFE0"
tools:context=
".TipActivity"
>
tools:context=
".TipActivity"
>
<com.qimai.android.widgetlib.topbar.QmTopBar
android:id=
"@+id/topBar"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
android:layout_width=
"match_parent"
app:title_text=
"提示"
android:layout_height=
"45dp"
/>
<Button
<Button
android:id=
"@+id/top"
android:id=
"@+id/top"
android:layout_width=
"90dp"
android:layout_width=
"90dp"
...
@@ -31,14 +39,28 @@
...
@@ -31,14 +39,28 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<
TextView
<
Button
android:
layout_width=
"wrap_content
"
android:
id=
"@+id/bottomnoArrow
"
android:layout_
height=
"wrap_content
"
android:layout_
width=
"150dp
"
android:
text=
"测试测试测试\n 测试测试测试
"
android:
layout_height=
"50dp
"
android:textColor=
"#C02F14"
android:
textSize=
"10s
p"
android:
layout_marginTop=
"160d
p"
a
pp:layout_constraintBottom_toBottomOf=
"parent
"
a
ndroid:text=
"bottomnoArrow
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
app:layout_constraintTop_toBottomOf=
"@+id/top"
/>
<Button
android:id=
"@+id/topnorrow"
android:layout_width=
"150dp"
android:layout_height=
"50dp"
android:layout_marginTop=
"172dp"
android:layout_marginEnd=
"60dp"
android:text=
"topnorrow"
app:layout_constraintEnd_toStartOf=
"@+id/bottomnoArrow"
app:layout_constraintHorizontal_bias=
"0.725"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/bottom"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_top_bar.xml
View file @
d7e5749a
...
@@ -62,5 +62,9 @@
...
@@ -62,5 +62,9 @@
</LinearLayout>
</LinearLayout>
<com.qimai.android.widgetlib.topbar.QmTopBar
android:id=
"@+id/topbar2"
android:layout_width=
"match_parent"
app:title_text=
"定义"
android:layout_height=
"45dp"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/goodmanager_pop_item.xml
0 → 100644
View file @
d7e5749a
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"35dp"
android:id=
"@+id/container"
android:layout_gravity=
"center"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_height=
"wrap_content"
>
<TextView
android:id=
"@+id/content"
android:layout_width=
"match_parent"
tools:text=
"堂食"
android:gravity=
"center"
android:textColor=
"#000000"
android:textSize=
"16sp"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/goodmanager_rightview_titlebar.xml
0 → 100644
View file @
d7e5749a
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"45dp"
android:layout_height=
"45dp"
android:background=
"#776F6F"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/rightText"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:layout_marginEnd=
"4dp"
android:textColor=
"#e63939"
android:textSize=
"17sp"
tools:text=
"堂食"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
d7e5749a
...
@@ -7,5 +7,11 @@
...
@@ -7,5 +7,11 @@
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
</style>
<style
name=
"tangshi"
>
<item
name=
"overlay_radius"
>
5dp
</item>
<item
name=
"overlay_bgColor"
>
#FFFFFF
</item>
<item
name=
"overlay_borderColor"
>
#C54545
</item>
<item
name=
"overlay_borderWidth"
>
1dp
</item>
</style>
</resources>
</resources>
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/QmTipOverlayDrawable.kt
View file @
d7e5749a
...
@@ -42,8 +42,8 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -42,8 +42,8 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
val
theme
=
context
.
theme
.
obtainStyledAttributes
(
val
theme
=
context
.
theme
.
obtainStyledAttributes
(
null
,
null
,
R
.
styleable
.
QmToolTipOverlay
,
R
.
styleable
.
QmToolTipOverlay
,
builder
.
defaultOverlayStyle
,
0
,
0
builder
.
defaultOverlayStyle
)
)
this
.
radius
=
this
.
radius
=
theme
.
getDimensionPixelSize
(
theme
.
getDimensionPixelSize
(
...
@@ -61,18 +61,18 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -61,18 +61,18 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
)
)
this
.
borderColor
=
theme
.
getColor
(
this
.
borderColor
=
theme
.
getColor
(
R
.
styleable
.
QmToolTipOverlay_overlay_borderColor
,
R
.
styleable
.
QmToolTipOverlay_overlay_borderColor
,
0
ContextCompat
.
getColor
(
context
,
R
.
color
.
QmTopBar_color_FFFFFFF
)
)
)
theme
.
recycle
()
theme
.
recycle
()
this
.
showArrow
=
builder
.
showArrow
this
.
showArrow
=
builder
.
showArrow
this
.
rectF
=
RectF
()
this
.
rectF
=
RectF
()
bgPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
bgPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
bgPaint
.
color
=
bgColor
bgPaint
.
color
=
bgColor
bgPaint
.
style
=
Paint
.
Style
.
FILL
bgPaint
.
style
=
Paint
.
Style
.
FILL
if
(
borderColor
!=
0
)
{
if
(
borderColor
!=
0
)
{
borderPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
borderPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
b
g
Paint
.
color
=
borderColor
b
order
Paint
.
color
=
borderColor
borderPaint
.
style
=
Paint
.
Style
.
STROKE
borderPaint
.
style
=
Paint
.
Style
.
STROKE
borderPaint
.
strokeJoin
=
Paint
.
Join
.
ROUND
borderPaint
.
strokeJoin
=
Paint
.
Join
.
ROUND
borderPaint
.
strokeWidth
=
borderWidth
.
toFloat
()
borderPaint
.
strokeWidth
=
borderWidth
.
toFloat
()
...
@@ -85,7 +85,10 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -85,7 +85,10 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
}
}
override
fun
draw
(
canvas
:
Canvas
)
{
override
fun
draw
(
canvas
:
Canvas
)
{
path
.
op
(
arrowPath
,
Path
.
Op
.
XOR
)
if
(
showArrow
)
{
path
.
op
(
arrowPath
,
Path
.
Op
.
UNION
)
}
bgPaint
?.
let
{
bgPaint
?.
let
{
canvas
.
drawPath
(
path
,
it
)
canvas
.
drawPath
(
path
,
it
)
}
}
...
@@ -141,7 +144,12 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -141,7 +144,12 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
bottom
=
bottom
bottom
=
bottom
)
)
}
else
{
}
else
{
rectF
.
set
(
left
.
toFloat
(),
top
.
toFloat
(),
right
.
toFloat
(),
bottom
.
toFloat
())
rectF
.
set
(
left
.
toFloat
()
+
borderWidth
,
top
.
toFloat
()
+
borderWidth
,
right
.
toFloat
()
-
borderWidth
,
bottom
.
toFloat
()
-
borderWidth
)
path
.
addRoundRect
(
rectF
,
radius
,
radius
,
Path
.
Direction
.
CW
)
path
.
addRoundRect
(
rectF
,
radius
,
radius
,
Path
.
Direction
.
CW
)
}
}
}
}
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/QmToolTip.kt
View file @
d7e5749a
...
@@ -45,6 +45,7 @@ class QmToolTip private constructor(
...
@@ -45,6 +45,7 @@ class QmToolTip private constructor(
private
val
containerPaddingSmall
=
10
private
val
containerPaddingSmall
=
10
private
var
containerMeasureWidth
=
0
private
var
containerMeasureWidth
=
0
private
var
containerMeasureHeight
=
0
private
var
containerMeasureHeight
=
0
private
var
arrowWeight
=
0f
private
constructor
(
builder
:
Builder
)
:
this
(
private
constructor
(
builder
:
Builder
)
:
this
(
builder
.
attachedView
,
builder
.
attachedView
,
...
@@ -52,6 +53,7 @@ class QmToolTip private constructor(
...
@@ -52,6 +53,7 @@ class QmToolTip private constructor(
builder
.
gravity
builder
.
gravity
)
{
)
{
checkMustParams
(
builder
)
checkMustParams
(
builder
)
arrowWeight
=
builder
.
arrowWeight
mWindow
.
width
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
mWindow
.
width
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
mWindow
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
mWindow
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
...
@@ -60,23 +62,32 @@ class QmToolTip private constructor(
...
@@ -60,23 +62,32 @@ class QmToolTip private constructor(
mWindow
.
isOutsideTouchable
=
true
mWindow
.
isOutsideTouchable
=
true
gravity
=
builder
.
gravity
gravity
=
builder
.
gravity
val
container
=
FrameLayout
(
builder
.
contentView
!!
.
context
)
val
container
=
FrameLayout
(
builder
.
contentView
!!
.
context
)
when
(
builder
.
gravity
)
{
if
(
builder
.
showArrow
)
{
Gravity
.
TOP
->
{
when
(
builder
.
gravity
)
{
container
.
setPadding
(
Gravity
.
TOP
->
{
containerPaddingSmall
,
container
.
setPadding
(
containerPaddingSmall
,
containerPaddingSmall
,
containerPaddingSmall
,
containerPaddingSmall
,
containerPaddingBig
containerPaddingSmall
,
)
containerPaddingBig
}
)
Gravity
.
BOTTOM
->
{
}
container
.
setPadding
(
Gravity
.
BOTTOM
->
{
containerPaddingSmall
,
container
.
setPadding
(
containerPaddingBig
,
containerPaddingSmall
,
containerPaddingSmall
,
containerPaddingBig
,
containerPaddingSmall
containerPaddingSmall
,
)
containerPaddingSmall
)
}
}
}
}
else
{
container
.
setPadding
(
containerPaddingSmall
,
containerPaddingSmall
,
containerPaddingSmall
,
containerPaddingSmall
)
}
}
container
.
addView
(
container
.
addView
(
builder
.
contentView
,
builder
.
contentView
,
...
@@ -113,7 +124,6 @@ class QmToolTip private constructor(
...
@@ -113,7 +124,6 @@ class QmToolTip private constructor(
if
(
containerMeasureHeight
>
remainOffset
)
{
if
(
containerMeasureHeight
>
remainOffset
)
{
// view的下边放不下了
// view的下边放不下了
val
containerParams
=
container
.
layoutParams
val
containerParams
=
container
.
layoutParams
if
(
containerParams
==
null
)
{
if
(
containerParams
==
null
)
{
container
.
layoutParams
=
ViewGroup
.
LayoutParams
(
container
.
layoutParams
=
ViewGroup
.
LayoutParams
(
...
@@ -224,7 +234,10 @@ class QmToolTip private constructor(
...
@@ -224,7 +234,10 @@ class QmToolTip private constructor(
private
fun
calculateBottomOffset
(
anchorView
:
View
):
Point
{
private
fun
calculateBottomOffset
(
anchorView
:
View
):
Point
{
val
point
=
Point
()
val
point
=
Point
()
point
.
x
=
attachedViewLocation
[
0
]
+
containerMeasureWidth
/
2
point
.
x
=
(
attachedViewLocation
[
0
]
+
anchorView
.
measuredWidth
/
2
-
containerMeasureWidth
*
arrowWeight
).
toInt
()
point
.
y
=
attachedViewLocation
[
1
]
+
anchorView
.
measuredHeight
point
.
y
=
attachedViewLocation
[
1
]
+
anchorView
.
measuredHeight
return
point
return
point
}
}
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/topbar/QmTopBar.kt
View file @
d7e5749a
...
@@ -215,7 +215,7 @@ class QmTopBar : Toolbar {
...
@@ -215,7 +215,7 @@ class QmTopBar : Toolbar {
if
(
params
==
null
)
{
if
(
params
==
null
)
{
rightParams
=
RelativeLayout
.
LayoutParams
(
rightParams
=
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
,
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
,
RelativeLayout
.
LayoutParams
.
WRAP_CONT
ENT
RelativeLayout
.
LayoutParams
.
MATCH_PAR
ENT
)
)
rightParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
rightParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
)
rightParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
)
...
...
widgetlib/src/main/res/values/styles.xml
View file @
d7e5749a
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
<resources>
<resources>
<style
name=
"QmToolTipOverlayDefault"
>
<style
name=
"QmToolTipOverlayDefault"
>
<item
name=
"overlay_radius"
>
19
dp
</item>
<item
name=
"overlay_radius"
>
5
dp
</item>
<item
name=
"overlay_bgColor"
>
@color/QmTopBar_color_FFFFFFF
</item>
<item
name=
"overlay_bgColor"
>
#ffffff
</item>
<item
name=
"overlay_borderColor"
>
@color/color_777777
</item>
<item
name=
"overlay_borderColor"
>
#FFFFFF
</item>
<item
name=
"overlay_borderWidth"
>
0.5
dp
</item>
<item
name=
"overlay_borderWidth"
>
1
dp
</item>
</style>
</style>
</resources>
</resources>
\ No newline at end of file
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