Hello to everybody.
Here is my problem:
In my android application I need to use custom menu. In xml I make menu layout (RelativLayout)
and inflate it on application start, then add it to parent layout, which was set by setContentView().
So I have something like this:
But I can't to set position for menu layout (using menu.layout(l, t, r, b)
.
menu.layout() don't do anything during initialization. I try to call layout() in
protected void onStart(), protected void onResume(), public void onChildViewAdded(View parent, View child) methods.
I try to create my custom class "class MenuLayout extends RelativeLayout{ ..." and set position in onLayout method:
But position of menu don't change.
menu.layout() begin to work later when, as I understand, parrent view is completely initialized because
next code works normally (position is changed):
PS: layout_graviti and graviti works very funny.., as always ))
Here is my problem:
In my android application I need to use custom menu. In xml I make menu layout (RelativLayout)
and inflate it on application start, then add it to parent layout, which was set by setContentView().
So I have something like this:
Code:
private void initMenu()
{
LayoutInflater inflanter = getLayoutInflater();
menu = (RelativeLayout) inflanter.inflate(R.layout.menu, null, false);
LayoutParams param = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
menuParent.addView(menu, param);
hideMenuAnim = AnimationUtils.loadAnimation(this, R.anim.menu_hide);
showMenuAnim = AnimationUtils.loadAnimation(this, R.anim.menu_show);
}
But I can't to set position for menu layout (using menu.layout(l, t, r, b)
.menu.layout() don't do anything during initialization. I try to call layout() in
protected void onStart(), protected void onResume(), public void onChildViewAdded(View parent, View child) methods.
I try to create my custom class "class MenuLayout extends RelativeLayout{ ..." and set position in onLayout method:
Code:
protected void onLayout(boolean changed, int l, int t, int r, int b) {
Rect posRect = new Rect();
callback.getPosition(posRect);
super.onLayout(changed, posRect.left, posRect.top, posRect.right, posRect.bottom);
}
But position of menu don't change.
menu.layout() begin to work later when, as I understand, parrent view is completely initialized because
next code works normally (position is changed):
Code:
public boolean onKeyDown (int keyCode, KeyEvent event)
{
if(KeyEvent.KEYCODE_DPAD_UP == keyCode)
{
menu.layout(menuPosRect.left, menuTopPos, menuPosRect.right, menuBottomPos);
}
...
}
PS: layout_graviti and graviti works very funny.., as always ))