- \r
- mWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);\r
- mWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);\r
- mWindow.setTouchable(true);\r
- mWindow.setFocusable(true);\r
- mWindow.setOutsideTouchable(true);\r
- \r
- mWindow.setContentView(root);\r
- }\r
- \r
- public void setBackgroundDrawable(Drawable background) {\r
- this.background = background;\r
- }\r
- \r
- public void setContentView(View root) {\r
- this.root = root;\r
- mWindow.setContentView(root);\r
- }\r
- \r
- public void setContentView(int layoutResId) {\r
- LayoutInflater inflater = \r
- (LayoutInflater) mAnchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
- setContentView(inflater.inflate(layoutResId, null));\r
- }\r
- \r
- public void showDropDown() {\r
- showDropDown(0, 0);\r
- }\r
- \r
- public void showDropDown(int x, int y) {\r
- preShow();\r
- mWindow.setAnimationStyle(android.R.style.Animation_Dialog);\r
- mWindow.showAsDropDown(mAnchor, x, y);\r
- }\r
- \r
- public void showLikeQuickAction() {\r
- showLikeQuickAction(0, 0);\r
- }\r
- \r
- public void showLikeQuickAction(int x, int y) {\r
- preShow();\r
- \r
- mWindow.setAnimationStyle(android.R.style.Animation_Dialog);\r
- int[] location = new int[2];\r
- mAnchor.getLocationOnScreen(location);\r
- \r
- Rect anchorRect = \r
- new Rect(location[0], location[1], location[0] + mAnchor.getWidth(), location[1] + mAnchor.getHeight());\r
- \r
- root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));\r
- root.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);\r
- \r
- int rootW = root.getWidth(), rootH = root.getHeight();\r
- int screenW = mWManager.getDefaultDisplay().getWidth();\r
- \r
- int xpos = ((screenW-rootW)/2) + x;\r
- int ypos = anchorRect.top - rootH + y;\r
- \r
- if (rootH > anchorRect.top) {\r
- ypos = anchorRect.bottom + y;\r