0

I want to use QuickAction dialog in my learning App, but I don't know how to change the size of the dialog. Now, the dialog is close to phone border, but I want to left blank between borders or reduce the width.
Thanks~ enter image description here

call setRootViewId(R.layout.notify_quick_action); at constructor.

public void setRootViewId(int id) {
        mRootView   = (ViewGroup) inflater.inflate(id, null);
        mTrack      = (ViewGroup) mRootView.findViewById(R.id.tracks);
        mArrowDown  = (ImageView) mRootView.findViewById(R.id.arrow_down);
        mArrowUp    = (ImageView) mRootView.findViewById(R.id.arrow_up);
        mRootView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        setContentView(mRootView);
    }


call show() at setOnItemClickListener()

public void show (View anchor) {
        preShow();

        int[] location = new int[2];
        mDidAction = false;

        anchor.getLocationOnScreen(location);
        Rect anchorRect = new Rect(location[0], location[1], location[0] + anchor.getWidth(), location[1] 
                            + anchor.getHeight());
        mRootView.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        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;
        }

        showArrow(((onTop) ? R.id.arrow_down : R.id.arrow_up), anchorRect.centerX()+180);

        setAnimationStyle(screenWidth, anchorRect.centerX(), onTop);
        Log.d("-------", "xPos="+xPos+";yPos="+yPos+";rootWidth="+rootWidth+";rootHeight="+rootHeight+";screenWidth="+screenWidth);
        mWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, 100, yPos);

        if (mAnimateTrack) mTrack.startAnimation(mTrackAnim);
    }
Kevin.Z
  • 135
  • 9
  • Perhaps help you: http://stackoverflow.com/questions/7926689/androidpopupwindow-showatlocation AND http://stackoverflow.com/questions/7440334/how-do-gravity-values-effect-popupwindow-showatlocation-in-android AND http://www.codota.com/android/methods/android.widget.PopupWindow/showAtLocation – A.A Feb 04 '15 at 11:29

1 Answers1

0

Just use custom PopupWindow. Yeah, here link: https://androidresearch.wordpress.com/2012/05/06/how-to-create-popups-in-android/

GIGAMOLE
  • 1,274
  • 1
  • 11
  • 17