Skip to content

Commit

Permalink
added: balloonColor
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuntae0117 committed Feb 7, 2019
1 parent 2e52840 commit b6eb0f5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion BalloonWindow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {


defaultConfig {
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ht.balloonwindow

import android.content.Context
import android.graphics.PorterDuff
import android.graphics.drawable.ColorDrawable
import android.support.constraint.ConstraintLayout
import android.support.constraint.ConstraintSet
Expand Down Expand Up @@ -32,6 +33,8 @@ class BalloonWindow : PopupWindow {
var paddingTop = 24.toPx()
var paddingBottom = 24.toPx()

var balloonColor: Int? = null

private var measuredContentsWidth: Int? = null
private var measuredContentsHeight: Int? = null

Expand Down Expand Up @@ -145,6 +148,11 @@ class BalloonWindow : PopupWindow {
LayoutInflater.from(context).inflate(R.layout.view_balloon, this, true)
contentsLl.addView(view)

if (balloonColor != null) {
arrowTopIv.setColorFilter(balloonColor!!, PorterDuff.Mode.SRC_ATOP)
arrowRightIv.setColorFilter(balloonColor!!, PorterDuff.Mode.SRC_ATOP)
contentsLl.background.setColorFilter(balloonColor!!, PorterDuff.Mode.SRC_ATOP)
}

val set = ConstraintSet()
set.constrainWidth(R.id.arrowRightIv, ConstraintSet.WRAP_CONTENT)
Expand Down
7 changes: 2 additions & 5 deletions BalloonWindow/src/main/res/layout/view_balloon.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootCl"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<merge xmlns:android="http://schemas.android.com/apk/res/android">

<android.support.constraint.ConstraintLayout
android:id="@+id/container"
Expand Down Expand Up @@ -31,4 +28,4 @@
android:src="@drawable/ic_balloon_arrow_top"/>

</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</merge>
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ht.example.balloonwindow"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.ht.example.balloonwindow

import android.graphics.Color
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.widget.TextView
import com.ht.balloonwindow.BalloonWindow
import kotlinx.android.synthetic.main.activity_main.*
Expand All @@ -14,20 +16,22 @@ class MainActivity : AppCompatActivity() {

aboveBtn.setOnClickListener {
val view = TextView(this)
view.text = "position:above\noffset:-35"
view.text = "position:above\noffset:-35\nballoonColor: #F79b00"

val window = BalloonWindow(this, targetView, BalloonWindow.Position.above)
window.balloonColor = Color.parseColor("#f79b00")
window.offset = -35
window.show(view)

}
belowBtn.setOnClickListener {
val view = TextView(this)
view.text = "position:below\noffset:55\nmargin:25"
view.text = "position:below\noffset:55\nmargin:25\nballoonColor: #f1f1f1"

val window = BalloonWindow(this, targetView, BalloonWindow.Position.below)
window.offset = 55
window.margin = 25
window.balloonColor = Color.parseColor("#f1f1f1")
window.show(view)
}
rightBtn.setOnClickListener {
Expand Down
Binary file modified screenshots/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b6eb0f5

Please sign in to comment.