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:
   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:
        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):
        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 ))

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to