1

This is image How can I dislay custom view same as when long pressed on search icon on below image?

my code

moha safi
  • 51
  • 7

2 Answers2

3

the feature you want to implement is called "Tooltip". Android default provides us to add a Tooltip to the View.

TooltipCompat.setTooltipText(imgSearch, "Your tooltip string here")

// "imgSearch" is your View/button/anything you want to add Tooltip to when user Long Presses it.

  • @mohasafi Please try this solution, for this you need not use any 3rd party library, and if it helps, you can mark it Approved/Correct. Thanks – Siddharth Thakkar Feb 11 '20 at 11:32
2

You can define title property in your menu file like below.


<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_call"
    android:title="Call"
    app:showAsAction="always"
    android:icon="@android:drawable/ic_menu_call" />
</menu>

If you not using menu, then just add below code into your onCreate method.


TooltipCompat.setTooltipText(your_view_id, "Your message here")
Dipakk Sharma
  • 976
  • 1
  • 8
  • 11