Giter Site home page Giter Site logo

viewtooltip's Introduction

ViewTooltip

screen

ViewTooltip
        .on(this, editText)
        .autoHide(true, 1000)
        .corner(30)
        .position(ViewTooltip.Position.RIGHT)
        .text("Right")
        .show();
Android app on Google Play

Download

Buy Me a Coffee at ko-fi.com

Download

dependencies {
    implementation 'com.github.florent37:viewtooltip:(last version)'
}

Methods

screen

ViewTooltip
        .on(this, editText)
        
        .autoHide(true / false, 1000)
        .clickToHide(true / false)
        
        .align(START / CENTER)
        
        .position(TOP / LEFT / RIGHT / BOTTOM)
        
        .text("The text")
        
        .textColor(Color.WHITE)
        .color(Color.BLACK)
        
        .corner(10)

        .arrowWidth(15)
        .arrowHeight(15)

        .distanceWithView(0)
        
        //change the opening animation
        .animation(new ViewTooltip.TooltipAnimation(){...})
        
        //listeners
        .onDisplay(new ViewTooltip.ListenerDisplay() {
            @Override
            public void onDisplay(View view) {
                
            }
        })
        .onHide(new ViewTooltip.ListenerHide() {
            @Override
            public void onHide(View view) {
                
            }
        })
        .show();

Prevent view to not be outside screen

ViewTooltip will not allow to be outside of screen, it will automatically adjust his size

screen

History

1.2.0

  • Compatible with AndroidX

1.1.7

  • Set text as Int
  • Added shadowColor

1.1.5

  • Use Fragment V4
  • Added aistanceWithView

1.1.4

  • Added arrowWidth / arrowHeight

1.1.3

  • Fix align bottom, text out of screen

1.1.1

  • Added shadow

1.0.8

  • Clip tooltip to screen (top / bottom)
  • Text format HTML

1.0.6

  • Fix align

1.0.5

  • .customView()
  • .remove()

1.0.3

  • Clip tooltip to screen width

1.0.2

  • Added corner

Credits

Author: Florent Champigny

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

Third Party Bindings

React Native

You may now use this library with React Native via the module here

License

Copyright 2017 Florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

viewtooltip's People

Contributors

anhmiuhv avatar cirnoftw avatar dogukandemir avatar florent37 avatar koox00 avatar m3sane avatar prscx avatar redman1037 avatar westnordost avatar yuriy-blinov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

viewtooltip's Issues

Set background with alpha channel but not including text

I tried to set color .color(int) with #8c1f7c82 which has alpha channel, text color is white, but I found that the output text is semi-transparent too. Is there way to keep the text color white without being semi-transparent?

singleton TooltipView [Feature Requested]

Single Tooptip view should display at a time
Can you add method to check weather tooltip view is already showing on screen.
if TooltipView is already showing then hide last.

Custom view width i showing incorrectly.

Is the width being set to a specific value? I see that the tooltip is having a specific width and wrapping all the text , the width is about 10% of the screen and tooltip overflows in height.

Getting rid of on(final View view) method

Read.me file and examples feature on(final View view) by default. But using it is dangerous because context is casted to Activity, which may fail with ClassCastException.

public static ViewTooltip on(final View view) {
    return new ViewTooltip(new MyContext((Activity) view.getContext()), view);
}

My app started to fail once I switched base theme to Theme.AppCompat.DayNight.DarkActionBar.
And after this my ActionBar MenyItem.getContext() was returning ContextThemeWrapper.

It maybe beneficial to users to change examples and readme to on(Activity activity, final View view) instead and maybe get rid of on(final View view) at all.

expect

Expect to be able to implement the other areas of the click prompt inside, and the hint will disappear.

Hide all tooltips

Hi @florent37
I am using this on RecyclerView, When it's scrolled i need to hide tooltips which are sticked to window.

I can use tooltip.close();

but i show lot of tooltips, so is there any method to hide all tooltips at once?

It doesn't work in case of DialogFragment

If i use ViewTooltip from a dialog fragment then it doesn't work and shows behind the dialog.

I used following code to show tooltip.
ViewTooltip.on(button)
.position(ViewTooltip.Position.BOTTOM)
.color(Color.GRAY)
.corner(30)
.textSize(TypedValue.COMPLEX_UNIT_DIP, 18)
.text(tooltip)
.clickToHide(true)
.autoHide(true, 3000)
.animation(new ViewTooltip.FadeTooltipAnimation(500))
.show();

Am i missing something to show it on top of the dialog?

Thanks,
Kalpesh

Activity needed?

ViewTooltip
.on - the first param needs activity, why? It should be enough the context.
Just want my tooltip to be available from a service

Allign center is wrong

in viewtooltip.java

switch (align) {
                    //case END:
                    //    spacingX = maxWidth - minWidth;
                    //    break;
                    case CENTER:
                        spacingX = (int) (-1f * maxWidth / 2f + minWidth / 2f);
                        break;
                    default:
                        spacingX = 0;
                        break;
                }

should the spacingX be (maxWidth - minWidth) / 2 ?

Two error

  1. can't on toolbar

  2. on fabButton , show position is wrong

Crash with exception: Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f0100b4 a=2}

Hi,

I'm getting a crash with a trace shown below.

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.project.app/com.project.camera.CameraActivity}: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f0100b4 a=2} at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2429) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493) at android.app.ActivityThread.access$800(ActivityThread.java:166) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5584) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) at dalvik.system.NativeStart.main(NativeStart.java) Caused by android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f0100b4 a=2} at android.content.res.Resources.loadColorStateList(Resources.java:3620) at android.content.res.TypedArray.getColorStateList(TypedArray.java:355) at android.widget.TextView.setTextAppearance(TextView.java:2612) at android.support.v4.widget.TextViewCompat$TextViewCompatBaseImpl.setTextAppearance(TextViewCompat.java:154) at android.support.v4.widget.TextViewCompat.setTextAppearance(TextViewCompat.java:475) at com.tooltip.Tooltip.getContentView(Tooltip.java:117) at com.tooltip.Tooltip.<init>(Tooltip.java:95) at com.tooltip.Tooltip.<init>(Tooltip.java:60) at com.tooltip.Tooltip$Builder.build(Tooltip.java:774) at com.project.camera.CameraActivity.onCreate(CameraActivity.java:100) at android.app.Activity.performCreate(Activity.java:5442) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493) at android.app.ActivityThread.access$800(ActivityThread.java:166) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5584) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) at dalvik.system.NativeStart.main(NativeStart.java)

The tooltip is set up as follows:

new Tooltip.Builder(view) .setText(text) .setTextSize(R.dimen.text_16) .setTextColor(Color.BLACK) .setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/SomeTypeFace.otf")) .setCornerRadius(R.dimen.tooltip_radius) .setBackgroundColor(Color.parseColor("#eae8ea")) .setGravity(Gravity.TOP) .setDismissOnClick(true) .setPadding((float) 50) .build();

What could be the problem here? Would highly appreciate any tips. @florent37

Manually hide a ToolTip

Is there a way to manually hide a tooltip?

For example, i want to hide a tooltip if the screen was pressed, not just if the tooltip was pressed...

Cannot Access Fragment

Hi,
I am getting following error at Compile Time
error: cannot access Fragment
class file for androidx.fragment.app.Fragment not found

Set tooltip width

Hi,

First of all thanx a lot for this lib it's very usefull for my project!

Is it possible to set tooltip width? If yes how? If no, I think it would be nice to add this feature.

The specified child already has a parent

Hi! First of all thx for your great library!

There is one issue in your library:
For example, we show tooltip from button1. If user taps on button1 twice or more, application will crash, because ViewTooltip didn't remove tooltip_view from it's parent before.

Row 87, ViewTooltip.java

ClassCastException in ViewTooltip.on

With the newest version of ViewTooltip (1.1.3), I am getting a few crash reports looking at the Google Play Console:

java.lang.ClassCastException: 
  at com.github.florent37.viewtooltip.ViewTooltip.on (ViewTooltip.java:54)
  at de.westnordost.streetcomplete.tangram.MapControlsFragment.showUnglueHint (MapControlsFragment.java:259)
  at de.westnordost.streetcomplete.tangram.MapControlsFragment.setTrackingButtonActivated (MapControlsFragment.java:251)
  at de.westnordost.streetcomplete.tangram.MapControlsFragment.onMapInitialized (MapControlsFragment.java:183)
  at de.westnordost.streetcomplete.tangram.MapFragment.tryInitializeMapControls (MapFragment.java:172)
  at de.westnordost.streetcomplete.tangram.MapFragment.onMapControlsCreated (MapFragment.java:165)
  at de.westnordost.streetcomplete.tangram.MapControlsFragment.onViewCreated (MapControlsFragment.java:145)

Tooltip not being clipped for Position.TOP

         mTimeToolTip
        .on(mStartTime)
        .clickToHide(true)
        .autoHide(false, 1000)
        .corner(30)
        .color(ContextCompat.getColor(mContext, R.color.datecart))
        .position(ViewTooltip.Position.TOP)
        .text("Chose a time for your date, \nwe'll also show you the weather")
        .show();

clipping_error

Incorrect position when tooltip set with rootView

Hi,
I've faced another issue while using it in my app, when .on method is used with rootView the position of tooltip is incorrect, check these screenshots

Screenshot 1: ViewTooltip.on(context, imgDot)...
Screenshot 2: ViewTooltip.on(context, relView, imgDot)...

scr1
scr2

Content going outside the screen bounds

Hi,
Is there a way to wrap the content such that the tooltip will encompass the entire text. Here is the problem I am facing:
ViewTooltip
.on(v)
.align(CENTER)
.position(ViewTooltip.Position.LEFT)
.text("Some tooltip with long text. What happens if this is really really long. Because the description of a category might go long. " + "What would happen to this sentence.")
.clickToHide(true)
.autoHide(false, 0)
.show();

screenshot

Padding doesn't work

When adding padding as a parameter it has no effect whatsoever on the tooltips, it's like i never put them.

Wrong position on Arabic Language

Today i checked my app on Arabic language. I found out that ViewToolTip showing with wrong position. I used ViewToolTip on Toolbar. In other language all good.

With RootView (RootView is DrawerLayout)

image

Without RootView. position(ViewTooltip.Position.BOTTOM)

image

Without RootView. position(ViewTooltip.Position.RIGHT)

image

Tooltip is cropped for long text

As shown here when tool tip text is very big the tool tip is cropped from right, tested on API 18 and API 24
screenshot_1505059168

it is even more noticeable when Align is set to START
screenshot_20170910-190936

ClassCastException:TintContextWrapper cannot be cast to android.app.Activity

Hi,
Im using OnePlus, OS version 4.4.4

Got this error:
java.lang.ClassCastException: android.support.v7.widget.TintContextWrapper cannot be cast to android.app.Activity
at com.github.florent37.viewtooltip.ViewTooltip.show(ViewTooltip.java:59)
at com.rhb.mobile.rhb_cambodia.SecretWordActivity.showTooltips(SecretWordActivity.java:146)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.