Reputation: 367
I had some textViews and image views in my app. On long pressing those views I need to show information regarding those views like in below picture. In this picture on long pressing icon of overflow menu some info is displayed.
How can I create a custom info view like this. Any ideas please...
Upvotes: 1
Views: 149
Reputation: 51
Just use tooltip
You can simply do this: Edit: For API 26+
view.tooltipText = "message"
Now, when you will longpress on your view it will automatically display the "message".
Also, you can use custom view instead of the default one.
Upvotes: 2
Reputation: 404
The answer of Mihir Shah is correct but according to documentation, it will only work from Android 8.0 (API level 26).
So if your app minimum SDK is Android 8.0 (API level 26) you can use
android:tooltipText="your message"
in your XML code. Or use
view.tooltipText = "message"
in your java code.
But if you target API level below 26 you need to use
TooltipCompat.setTooltipText(view, "your message");
also make sure your gradle have implementation 'androidx.appcompat:appcompat:1.3.1'
this dependency.
Upvotes: 3