Android grow LinearLayout using animation

后端 未结 4 694
灰色年华
灰色年华 2021-02-05 11:31

I am trying to use animation to make a layout appear on screen. The idea is that layout will start with height of 0 and grow to 100%.

I have real troubles with this and

4条回答
  •  情话喂你
    2021-02-05 12:00

    Ok, I figured it out.

    Animation XML layout

    
    
    
     
    
    
    

    Layout XML file

    
    
    
    
      
        
        
        

    and my Activity class

    public class MyActivity extends Activity{
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     }
    
    public void animate(View view){
        LinearLayout dialog   = (LinearLayout)findViewById(R.id.dialog);
        dialog.setVisibility(LinearLayout.VISIBLE);
        Animation animation   =    AnimationUtils.loadAnimation(this, R.anim.anim);
        animation.setDuration(500);
        dialog.setAnimation(animation);
        dialog.animate();
        animation.start();
     }
    
    }
    

提交回复
热议问题