Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have an android dialog which i want to position in a specific position in its window.
I'm using API 8
how come
int a == -2
and
int b == 153
are not positive?
what is the difference between
getLayoutParams().height;
mToolTipLayout.getHeight();
I have the following code
public void initViews(int orientation) {
mToolTipLayout = ((LinearLayout) findViewById(R.id.tooltip_layout));
ViewTreeObserver vto = mToolTipLayout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mToolTipLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
setPosition();
private void setPosition() {
int a = mToolTipLayout.getLayoutParams().height;
int b = mToolTipLayout.getHeight();
–
–
Layout params specify how the measure and layout process should work. They are not updated in the measure/layout process. -2
is the value for WRAP_CONTENT
.
The measures themselves are available in the views themselves, not their layout params. 153
is the measured pixel height in your case, measured with WRAP_CONTENT
spec.
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.