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