Description
I have an app which contains two Text Views in the center of the screen. The first one has my name (Tomás). The second has my last name. These txt views are clickable and by doing so a Tooltip will appear which will display my middle or last name as clicked.
Problem:
The problem is that when you touch both, the tooltips will overlap each other.
I would like that when touching a text, a tooltip disappears so that only the one that was selected can be seen (That is, there can never be two tooltips on the screen).
I attach the JAVA code of my tooltips
//TXT NOMBRE EVENT LISTENER
txt_nombre.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView txt = (TextView) v;
final Tooltip tooltip = new Tooltip.Builder(txt)
.setText("Ariel")
.setTextColor(Color.parseColor("#ffffff"))
.setGravity(Gravity.TOP)
.setCornerRadius(8f)
.setDismissOnClick(true)
.setArrowHeight(18f)
.show();
p.handler.postDelayed(new Runnable() {
@Override
public void run() {
tooltip.dismiss();
}
},3000);
}
});
Dependence:
implementation 'com.github.vihtarb:tooltip:0.1.9'
Thank you for reading!!
I imagine you are using vihtarb:tooltip, in that case this should fix your problem.
To individually cancel each ToolTip you have to define two different instances one for the first name and one for the last name,
In this way you can verify if the
tooltipApellido
calldismiss()
to cancel it exists, you would do the same for the case of tooltipSurname, you verify if it existstooltipNombre
and you calldismiss()
to close it: