jayrambhia / Tooltip

Lightweight Tooltip library for Android
Apache License 2.0
205 stars 25 forks source link

In Fragment when I click on ImageView it shows and after showing it gets disappeared in just a second? #20

Open swatiomar opened 4 years ago

swatiomar commented 4 years ago

I used Tooltip.builder() in Fragment but when I click on ImageView it shows and after showing whole it gets disappeared in just a second? Please suggest me.

Please find logs here: 2020-05-06 16:36:19.390 25288-25288/com.ikea.tradfri.lighting I/Tooltip: child layout: left: 435 top: -759 right: 794 bottom: -682 2020-05-06 16:36:19.391 25288-25288/com.ikea.tradfri.lighting I/Tooltip: px: 767, py: -771 2020-05-06 16:36:19.392 25288-25288/com.ikea.tradfri.lighting D/Tooltip: anchor point: 767, -771 2020-05-06 16:36:19.392 25288-25288/com.ikea.tradfri.lighting D/Tooltip: size: 359, 77 2020-05-06 16:36:51.415 25288-25288/com.ikea.tradfri.lighting I/Tooltip: l: 0, t: 849, r: 824, b: 849 2020-05-06 16:36:51.447 25288-25288/com.ikea.tradfri.lighting I/Tooltip: onPreDraw: 940, 595 2020-05-06 16:36:51.447 25288-25288/com.ikea.tradfri.lighting D/Tooltip: anchor location: 940, 595 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: holder location: 188, 1402 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: child w: 359 h: 77 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: left: 752, top: -807 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: tip top Before: -807 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: tip top: -759 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: tip Move to: 767 -771 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: tip Line to: 761 -759 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: tip Line to: 773 -759 2020-05-06 16:36:51.448 25288-25288/com.ikea.tradfri.lighting D/Tooltip: tip Line to: 767 -771 2020-05-06 16:36:51.449 25288-25288/com.ikea.tradfri.lighting I/Tooltip: child layout: left: 435 top: -759 right: 794 bottom: -682 2020-05-06 16:36:51.449 25288-25288/com.ikea.tradfri.lighting I/Tooltip: px: 767, py: -771 2020-05-06 16:36:51.451 25288-25288/com.ikea.tradfri.lighting D/Tooltip: anchor point: 767, -771 2020-05-06 16:36:51.452 25288-25288/com.ikea.tradfri.lighting D/Tooltip: size: 359, 77 2020-05-06 16:36:54.729 25288-25288/com.ikea.tradfri.lighting I/Tooltip: canvas w: 824, h: 0

private void showCustomTooltip(@nonnull View anchor) {

@SuppressLint("InflateParams") View content = getLayoutInflater().inflate(R.layout.item_tooltip_view_1, null);
Resources res = getResources();

int tooltipPadding = res.getDimensionPixelOffset(R.dimen.tooltip_padding);
int tooltipColor = ContextCompat.getColor(mBaseActivity, R.color.warning_text_color);
int tipSizeSmall = res.getDimensionPixelSize(R.dimen.tip_dimen_small);
int tipRadius = res.getDimensionPixelOffset(R.dimen.tip_radius);

customTooltip = new Tooltip.Builder(getActivity())
        .anchor(anchor, Tooltip.BOTTOM)
        .animate(new TooltipAnimation(TooltipAnimation.SCALE_AND_FADE, 400))
        .autoAdjust(true)
        .withPadding(tooltipPadding)
        .withMargin(6)
        .content(content)
        .cancelable(true)
        .checkForPreDraw(true)
        .withTip(new Tooltip.Tip(tipSizeSmall, tipSizeSmall, tooltipColor))
        .into(mRootLayout)
        .debug(true)
        .show();

}

jayrambhia commented 4 years ago

Thanks for creating an issue. Can you upload a video of this behavior?

jayrambhia commented 4 years ago

Also, based on the log, it seems that the anchor point is not on the screen => anchor point: 767, -771. Perhaps, that could be an issue.

swatiomar commented 4 years ago

Hi @jayrambhia,

PFA video link for reference,

VID-20200507-WA0008.zip

One more thing I want to specify here as you can see in video clearly there is complex view hierarchy. Is that issue or How can I resolve that issue? Please suggest. Is there any other thing which I miss?

jayrambhia commented 4 years ago

Hey @swatiomar , I tried your code in a fragment and it seems to work fine. device-2020-05-08-114922.webm.zip

Are you using some fork of this lib? Because there's no setMargin method. Plus, what type is mRootLayout? Is your anchor in a RecyclerView?