0

I have created an array of buttons consisting of 6 rows and 7 columns.Now what i want to do is when the app is load i want my button shake on first appereance.I mean to say that i want to give animation effect to my buttons.Mean whenever app is loaded the buttons appears shake to the user for a sec.So can anyone tell me how that can be done.I have send my code for creating array of buttons.Please anyone help me how can i give this effect to my buttons.

code for creating Array of Buttons:

            LinearLayout layoutVertical = (LinearLayout) findViewById(R.id.liVLayout);
            LinearLayout rowLayout = null;

            LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT,1);

            //Create Button
            for (int i = 0; i<6; i++)
            {
                rowLayout = new LinearLayout(this);
                rowLayout.setWeightSum(7);
                layoutVertical.addView(rowLayout, param);

                for(int j=0; j<7; j++){
                    m_pBtnDay[i][j] = new Button(this);
                    rowLayout.addView(m_pBtnDay[i][j], param); 
                    m_pBtnDay[i][j].setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
                    m_pBtnDay[i][j].setOnLongClickListener(this);                           
                    m_pBtnDay[i][j].setOnClickListener(this);

                    //save button position
                    m_pBtnDay[i][j].setTag(new CalendarForm(i , j));}
            }
AndroidDev
  • 4,521
  • 24
  • 78
  • 126

2 Answers2

0

Create an animation.. Animation anim= AnimationUtils.loadFromRes(int xyz); something like this. Then set this animation to button... in for loop. urButton.setAnimation(); then when u want to play animation just call startanimation method. urButton.startAnimation();

om252345
  • 2,395
  • 4
  • 29
  • 31
0

Refer the ApiDemo sample project that comes with the sdk. There is one animation where they have a textbox that rattles when you enter text into it and press a button. You can modify that for your needs.

Ron
  • 24,175
  • 8
  • 56
  • 97