douglasjunior / android-simple-tooltip

A simple library based on PopupWindow to create Tooltips on Android. 💚

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add shadow to tooltip

kashifo opened this issue · comments

Hi,
How can i show the tooltip with shadow?
Because tooltip with same color as background is not visible.

Here's my scenario:
My tooltip is of white color, and background of activity is dynamic, so sometimes background is white color, at this time the tooltip is not visible without any border or shadow.

Take a look at the Custom Layout Sample:

Code:

final SimpleTooltip tooltip = new SimpleTooltip.Builder(this)
.anchorView(v)
.text(R.string.btn_modal_custom)
.gravity(Gravity.TOP)
.dismissOnOutsideTouch(false)
.dismissOnInsideTouch(false)
.modal(true)
.animated(true)
.animationDuration(2000)
.animationPadding(SimpleTooltipUtils.pxFromDp(50))
.contentView(R.layout.tooltip_custom, R.id.tv_text)
.focusable(true)
.build();

Layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_tooltip"
android:orientation="vertical">

Background:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp" />
<solid android:color="@color/colorAccent" />
</shape>

And then, try something like this: https://stackoverflow.com/a/15333015/2826279

the shadow even is added to the arrow? otherwise , a shadow will be added at the top to the arrow since the arrow does not belong to the layout (tooltip_custom.xml)