0
내 프로젝트에 빠른 액션을 구축하려고합니다. 보기를 클릭하면 팝업 창이 제대로 표시됩니다. 하지만 부모보기를 가리키는 화살표 (위쪽 화살표, 아래쪽 화살표)가 표시되지 않습니다. 나는 여러면에서 그것을 시도했다. 어떤 사람이 더 나은 솔루션 또는 좋은 논리가 있다면 나에게 감사를 도와주세요 :표시 사용자 정의 QuickAction 팝업 창 안드로이드에
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());
}
및 showArrow 방법과 같습니다 : 가 여기에 코드를 볼 수 있습니다
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);
}
xml 파일을 공유합니다. –