Reality of animation effects when Android layout changes (1)

Source: Internet
Author: User

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:
 
     
  
 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.