MainActivity is as follows:
Package cc. test; import android. app. activity; import android. content. context; import android. OS. bundle; import android. view. view; import android. view. view. onClickListener; import android. widget. button; import android. widget. linearLayout; import android. widget. textView;/*** Demo Description: * the reality of the animation effect when the layout changes (1) * This mainly tests the animateLayoutChanges attribute in the layout * displays an animation when the layout changes, it won't be too hard to switch. ** example Description: * click TextView to add a button to the linear layout. * To enable the animation effect when adding a button, we set the property * android: animateLayoutChanges = "true" * the default animation effect is displayed when you add a View to the layout. ** of course, this is only a default animation effect. if you need to customize the animation effect, * attribute animation is required. For details, see the reality of the animation effect when the layout of the next article changes (ii) ** references: * 1 http://developer.android.com/training/animation/layout.html * 2 http://blog.csdn.net/think_soft/article/details/12417107 * Thank you very much */public class extends Activity {private LinearLayout mRootLinearLayout; private Context mContext; private TextView mTextView; @ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main); init ();} private void init () {mContext = this; mRootLinearLayout = (LinearLayout) findViewById (R. id. rootLinearLayout); mTextView = (TextView) findViewById (R. id. textView); mTextView. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {Button button = new Button (mContext); button. setText ("button"); mRootLinearLayout. addView (button );}});}}
Main. xml is as follows: