Comments (4)
A related problem is that the arrow position also gets messed up if you add different sized content to an existing quickaction object or try right aligning the control on a very small button.
the reason is because of the way the arrow left margin is calculated. would be nice if it were fixed.
from newquickaction3d.
Dudes, I solved your problem and I think this could be fixed in the main release too:
Replace the show function of the class QuickAction with the following:
public void show (View anchor) {
preShow();
int xPos, yPos, arrowPos; // int arrowPos is needed cause position of arrow has to be diffrent for buttons that are small and aligned to the right
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(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mRootView.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int rootHeight = mRootView.getMeasuredHeight();
int rootWidth = mRootView.getMeasuredWidth();
int screenWidth = mWindowManager.getDefaultDisplay().getWidth();
int screenHeight = mWindowManager.getDefaultDisplay().getHeight();
//automatically get X coord of popup (top left)
if ((anchorRect.left + rootWidth) > screenWidth) {
xPos = anchorRect.right - (rootWidth-anchor.getWidth());
arrowPos = anchorRect.right-xPos; // normally it is anchorRect.left-xPos but then there is a gap which is getting bigger on pressing the button a few times.
} else {
if (anchor.getWidth() > rootWidth) {
xPos = anchorRect.centerX() - (rootWidth/2);
} else {
xPos = anchorRect.left;
}
arrowPos = anchorRect.centerX()-xPos; // that is the developers default
}
int dyTop = anchorRect.top;
int dyBottom = screenHeight - anchorRect.bottom;
boolean onTop = (dyTop > dyBottom) ? true : false;
if (onTop) {
if (rootHeight > dyTop) {
yPos = 15;
LayoutParams l = mScroller.getLayoutParams();
l.height = dyTop - anchor.getHeight();
} else {
yPos = anchorRect.top - rootHeight;
}
} else {
yPos = anchorRect.bottom;
if (rootHeight > dyBottom) {
LayoutParams l = mScroller.getLayoutParams();
l.height = dyBottom;
}
}
showArrow(((onTop) ? R.id.arrow_down : R.id.arrow_up), arrowPos); // replaced developers default value with the var so in special cases the popup AND the arrow are displayed constrained to the right
setAnimationStyle(screenWidth, anchorRect.centerX(), onTop);
mWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, xPos, yPos);
}
You can see a screenshot here: http://twitpic.com/6w4lnj (sorry for motion blur but I'm not allowed to show the layout of the app currently :/)
Hope I could help you!
from newquickaction3d.
This bug has been fixed on current update, thanx TheVaan for giving me the clue..
from newquickaction3d.
2 things - the existing update to the main line doesnt work properly for me.
- on rotation it calculates the arrow location incorrectly. I did this to fix :
//automatically get X coord of popup (top left)
//if ((anchorRect.left + rootWidth) > screenWidth) {
xPos = anchorRect.left - (rootWidth-anchor.getWidth());
xPos = (xPos < 0) ? 0 : xPos;
arrowPos = anchorRect.centerX()-xPos;
/} else {
if (anchor.getWidth() > rootWidth) {
xPos = anchorRect.centerX() - (rootWidth/2);
} else {
xPos = anchorRect.left;
}
arrowPos = anchorRect.centerX()-xPos;
}/
- on my devices I needed to restore the line:
mRootView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
without it I just get exceptions.
from newquickaction3d.
Related Issues (19)
- Positioning button and title in the action item
- maven support HOT 1
- Why complete new repository?
- problem with listview HOT 1
- yPos does not offset window decoration
- mquickAction.addActionItem(faceItem); return nullpointer exeption HOT 1
- How to increase the text font size ?
- Crash after few times showing the quickaction HOT 3
- Mote than 5 Menu in Screen ?
- Migrate from NewQuickAction to NewQuickAction3D
- YouTube
- click on ActionItem sometimes cause popup window transparent HOT 6
- bin folder under version control
- error when use as library
- Inflate actions from XML file
- Problem with many QuickActionItem s
- Orientation Problem
- grid mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from newquickaction3d.