J'essaie de construire l'action rapide dans mon projet. quand je clique sur la vue, la fenêtre pop-up s'affiche correctement. Mais la flèche (flèche vers le haut, flèche vers le bas) qui pointe vers la vue parent n'est pas visible. Je l'ai essayé de plusieurs façons. si quelqu'un a la meilleure solution ou une bonne logique s'il vous plaît me aider grâce: Ici vous pouvez voir le code:show Fenêtre contextuelle QuickAction personnalisée dans android
public void show (View anchor) {
preShow();
int[] location = new int[2];
anchor.getLocationOnScreen(location);
Rect anchorRect = new Rect(location[0], location[1], location[0] + anchor.getWidth(), location[1]
+ anchor.getHeight());
mRootView.setLayoutParams(new LayoutParams(300, 400));
mRootView.measure(200,300);
int rootWidth = mRootView.getMeasuredWidth();
int rootHeight = mRootView.getMeasuredHeight();
int screenWidth = mWindowManager.getDefaultDisplay().getWidth();
int xPos = (screenWidth - rootWidth)/2;
int yPos = anchorRect.top - rootHeight;
boolean onTop = true;
if (rootHeight > anchor.getTop()) {
yPos = anchorRect.bottom;
onTop = false;
}
if(onTop==true){
showArrow(R.id.arrow_down, anchorRect.centerX());
}
else
{
showArrow(R.id.arrow_up, anchorRect.centerX());
}
et la méthode showArrow est aussi:
private void showArrow(int whichArrow, int requestedX) {
final View showArrow;
final View hideArrow;
if(whichArrow==R.id.arrow_down)
{
showArrow=mArrowDown;
hideArrow=mArrowUp;
}
else{
showArrow=mArrowUp;
hideArrow=mArrowDown;
}
final int arrowWidth = mArrowUp.getMeasuredWidth();
showArrow.setVisibility(View.VISIBLE);
ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams)showArrow.getLayoutParams();
param.leftMargin = requestedX - arrowWidth/2;
hideArrow.setVisibility(View.INVISIBLE);
}
partagez votre fichier XML. –