Java Code Examples for android.animation.LayoutTransition#setAnimator()
The following examples show how to use
android.animation.LayoutTransition#setAnimator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyAnimationActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
private void doLayoutAnimator() { LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, getObjectAnimator(false)); layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, getObjectAnimator(true)); layoutTransition.setDuration(2000); //mPuppet's parentView ViewGroup contentView = (ViewGroup) ((ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0); contentView.setLayoutTransition(layoutTransition); if (contentView.findViewById(R.id.view_puppet) == null) { contentView.addView(mPuppet); } else { contentView.removeView(mPuppet); } }
Example 2
Source File: LayoutAnimations.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
private void setupTransition(LayoutTransition transition) { CheckBox customAnimCB = (CheckBox) findViewById(R.id.customAnimCB); CheckBox appearingCB = (CheckBox) findViewById(R.id.appearingCB); CheckBox disappearingCB = (CheckBox) findViewById(R.id.disappearingCB); CheckBox changingAppearingCB = (CheckBox) findViewById(R.id.changingAppearingCB); CheckBox changingDisappearingCB = (CheckBox) findViewById(R.id.changingDisappearingCB); transition.setAnimator(LayoutTransition.APPEARING, appearingCB.isChecked() ? (customAnimCB.isChecked() ? customAppearingAnim : defaultAppearingAnim) : null); transition.setAnimator(LayoutTransition.DISAPPEARING, disappearingCB.isChecked() ? (customAnimCB.isChecked() ? customDisappearingAnim : defaultDisappearingAnim) : null); transition.setAnimator(LayoutTransition.CHANGE_APPEARING, changingAppearingCB.isChecked() ? (customAnimCB.isChecked() ? customChangingAppearingAnim : defaultChangingAppearingAnim) : null); transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changingDisappearingCB.isChecked() ? (customAnimCB.isChecked() ? customChangingDisappearingAnim : defaultChangingDisappearingAnim) : null); }
Example 3
Source File: AnimUtil.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
private static LayoutTransition a() { LayoutTransition layouttransition = new LayoutTransition(); layouttransition.setDuration(90L); layouttransition.setInterpolator(2, new AccelerateDecelerateInterpolator()); layouttransition.setInterpolator(3, new AccelerateDecelerateInterpolator()); ObjectAnimator objectanimator = ObjectAnimator.ofFloat(null, "rotationX", new float[] { 90F, 0.0F }).setDuration(layouttransition.getDuration(2)); layouttransition.setAnimator(2, objectanimator); objectanimator.addListener(new d()); ObjectAnimator objectanimator1 = ObjectAnimator.ofFloat(null, "rotationX", new float[] { 0.0F, -90F }).setDuration(layouttransition.getDuration(3)); layouttransition.setAnimator(3, objectanimator1); objectanimator1.addListener(new e()); return layouttransition; }
Example 4
Source File: CardStreamLinearLayout.java From android-play-places with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void setCardStreamAnimator( CardStreamAnimator animators ){ if( animators == null ) mAnimators = new CardStreamAnimator.EmptyAnimator(); else mAnimators = animators; LayoutTransition layoutTransition = getLayoutTransition(); if( layoutTransition != null ){ layoutTransition.setAnimator( LayoutTransition.APPEARING, mAnimators.getAppearingAnimator(getContext()) ); layoutTransition.setAnimator( LayoutTransition.DISAPPEARING, mAnimators.getDisappearingAnimator(getContext()) ); } }
Example 5
Source File: LayoutAnimationsActivity.java From AndroidAnimationExercise with Apache License 2.0 | 6 votes |
private void setupTransition(LayoutTransition transition) { CheckBox customAnimCB = (CheckBox) findViewById(R.id.customAnimCB); CheckBox appearingCB = (CheckBox) findViewById(R.id.appearingCB); CheckBox disappearingCB = (CheckBox) findViewById(R.id.disappearingCB); CheckBox changingAppearingCB = (CheckBox) findViewById(R.id.changingAppearingCB); CheckBox changingDisappearingCB = (CheckBox) findViewById(R.id.changingDisappearingCB); transition.setAnimator(LayoutTransition.APPEARING, appearingCB.isChecked() ? (customAnimCB.isChecked() ? customAppearingAnim : defaultAppearingAnim) : null); transition.setAnimator(LayoutTransition.DISAPPEARING, disappearingCB.isChecked() ? (customAnimCB.isChecked() ? customDisappearingAnim : defaultDisappearingAnim) : null); transition.setAnimator(LayoutTransition.CHANGE_APPEARING, changingAppearingCB.isChecked() ? (customAnimCB.isChecked() ? customChangingAppearingAnim : defaultChangingAppearingAnim) : null); transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changingDisappearingCB.isChecked() ? (customAnimCB.isChecked() ? customChangingDisappearingAnim : defaultChangingDisappearingAnim) : null); }
Example 6
Source File: GiftControl.java From LiveGiftLayout with Apache License 2.0 | 6 votes |
/** * @param giftLayoutParent 存放礼物控件的父容器 * @param giftLayoutNums 礼物控件的数量 * @return */ public GiftControl setGiftLayout(LinearLayout giftLayoutParent, @NonNull int giftLayoutNums) { if (giftLayoutNums <= 0) { throw new IllegalArgumentException("GiftFrameLayout数量必须大于0"); } if (giftLayoutParent.getChildCount() > 0) {//如果父容器没有子孩子,就进行添加 return this; } mGiftLayoutParent = giftLayoutParent; mGiftLayoutMaxNums = giftLayoutNums; LayoutTransition transition = new LayoutTransition(); transition.setAnimator(LayoutTransition.CHANGE_APPEARING, transition.getAnimator(LayoutTransition.CHANGE_APPEARING)); transition.setAnimator(LayoutTransition.APPEARING, transition.getAnimator(LayoutTransition.APPEARING)); transition.setAnimator(LayoutTransition.DISAPPEARING, transition.getAnimator(LayoutTransition.CHANGE_APPEARING)); transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, transition.getAnimator(LayoutTransition.DISAPPEARING)); mGiftLayoutParent.setLayoutTransition(transition); return this; }
Example 7
Source File: LayoutTransitionFragment.java From AndroidAll with Apache License 2.0 | 6 votes |
private LayoutTransition createTransitionChange() { LayoutTransition mTransitioner = new LayoutTransition(); //入场动画:view在这个容器中消失时触发的动画 ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "rotationY", 0f, 360f, 0f); mTransitioner.setAnimator(LayoutTransition.APPEARING, animIn); //出场动画:view显示时的动画 ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "rotation", 0f, 90f, 0f); mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut); PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 100, 0); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 0); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 0); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 0); Animator changeAppearAnimator = ObjectAnimator.ofPropertyValuesHolder(layoutTransitionGroup, pvhLeft, pvhTop, pvhRight, pvhBottom); mTransitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, changeAppearAnimator); /* 1, LayoutTransition.CHANGE_APPEARING/CHANGE_DISAPPEARING 必须配合PropertyValuesHolder使用才能有效果(使用ObjectAnimator无效). */ return mTransitioner; }
Example 8
Source File: PropertyAnimationActivity.java From Android-Animation-Set with Apache License 2.0 | 6 votes |
private void doLayoutAnimator() { LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, getObjectAnimator(false)); layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, getObjectAnimator(true)); layoutTransition.setDuration(2000); //mPuppet's parentView ViewGroup contentView = (ViewGroup) ((ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0); contentView.setLayoutTransition(layoutTransition); if (contentView.findViewById(R.id.view_puppet) == null) { contentView.addView(mPuppet); } else { contentView.removeView(mPuppet); } }
Example 9
Source File: CardStreamLinearLayout.java From sensors-samples with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void setCardStreamAnimator( CardStreamAnimator animators ){ if( animators == null ) mAnimators = new CardStreamAnimator.EmptyAnimator(); else mAnimators = animators; LayoutTransition layoutTransition = getLayoutTransition(); if( layoutTransition != null ){ layoutTransition.setAnimator( LayoutTransition.APPEARING, mAnimators.getAppearingAnimator(getContext()) ); layoutTransition.setAnimator( LayoutTransition.DISAPPEARING, mAnimators.getDisappearingAnimator(getContext()) ); } }
Example 10
Source File: LayoutTransitionFragment.java From AndroidAll with Apache License 2.0 | 5 votes |
private LayoutTransition createTransition() { LayoutTransition mTransitioner = new LayoutTransition(); //入场动画:view在这个容器中消失时触发的动画 ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "rotationY", 0f, 360f, 0f); mTransitioner.setAnimator(LayoutTransition.APPEARING, animIn); //出场动画:view显示时的动画 ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "rotation", 0f, 90f, 0f); mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut); return mTransitioner; }
Example 11
Source File: CardStreamLinearLayout.java From sensors-samples with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); Log.d(TAG, "onLayout: " + changed); if( changed && !mLayouted ){ mLayouted = true; ObjectAnimator animator; LayoutTransition layoutTransition = new LayoutTransition(); animator = mAnimators.getDisappearingAnimator(getContext()); layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, animator); animator = mAnimators.getAppearingAnimator(getContext()); layoutTransition.setAnimator(LayoutTransition.APPEARING, animator); layoutTransition.addTransitionListener(mTransitionListener); if( animator != null ) layoutTransition.setDuration(animator.getDuration()); setLayoutTransition(layoutTransition); if( mShowInitialAnimation ) runInitialAnimations(); if (mFirstVisibleCardTag != null) { scrollToCard(mFirstVisibleCardTag); mFirstVisibleCardTag = null; } } }
Example 12
Source File: MainActivity.java From adjustablelayout with Apache License 2.0 | 5 votes |
private void initAppBarLayout(){ LayoutTransition mTransition = new LayoutTransition(); /** * 添加View时过渡动画效果 */ ObjectAnimator addAnimator = ObjectAnimator.ofFloat(null, "translationY", 0, 1.f). setDuration(mTransition.getDuration(LayoutTransition.APPEARING)); mTransition.setAnimator(LayoutTransition.APPEARING, addAnimator); //header layout height final int headerHeight = getResources().getDimensionPixelOffset(R.dimen.header_height); mAppBarLayout = (AppBarLayout) findViewById(R.id.appbar); mAppBarLayout.setLayoutTransition(mTransition); mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { verticalOffset = Math.abs(verticalOffset); if ( verticalOffset >= headerHeight ){ isHideHeaderLayout = true; //当偏移量超过顶部layout的高度时,我们认为他已经完全移动出屏幕了 new Handler().postDelayed(new Runnable() { @Override public void run() { AppBarLayout.LayoutParams mParams = (AppBarLayout.LayoutParams) headerLayout.getLayoutParams(); mParams.setScrollFlags(0); headerLayout.setLayoutParams(mParams); headerLayout.setVisibility(View.GONE); } },100); } } }); }
Example 13
Source File: CardStreamLinearLayout.java From android-play-places with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); Log.d(TAG, "onLayout: " + changed); if( changed && !mLayouted ){ mLayouted = true; ObjectAnimator animator; LayoutTransition layoutTransition = new LayoutTransition(); animator = mAnimators.getDisappearingAnimator(getContext()); layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, animator); animator = mAnimators.getAppearingAnimator(getContext()); layoutTransition.setAnimator(LayoutTransition.APPEARING, animator); layoutTransition.addTransitionListener(mTransitionListener); if( animator != null ) layoutTransition.setDuration(animator.getDuration()); setLayoutTransition(layoutTransition); if( mShowInitialAnimation ) runInitialAnimations(); if (mFirstVisibleCardTag != null) { scrollToCard(mFirstVisibleCardTag); mFirstVisibleCardTag = null; } } }
Example 14
Source File: PbChatActivity.java From imsdk-android with MIT License | 5 votes |
/** * 显示搜索按钮 */ @SuppressLint("ObjectAnimatorBinding") private void showSearchView() { if (isFinishing()) { return; } final TipsFloatView tipsFloatView = new TipsFloatView(this); tipsFloatView.setTag(TAG_SEARCH_VIEW); tipsFloatView.setClickListener(v -> { Intent intent = ReflectUtil.getQtalkServiceRNActivityIntent(PbChatActivity.this); if(intent == null){ return; } intent.putExtra("module", "Search"); intent.putExtra("Version", "1.0.0"); intent.putExtra("xmppid", jid); intent.putExtra("realjid", realJid); intent.putExtra("chatType", chatType); intent.putExtra("Screen", "LocalSearch"); startActivity(intent); clearSearchTip(); }); final LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(this, "scaleX", 0, 1)); getHandler().postDelayed(() -> { if(!isFinishing()){ chating_view.setLayoutTransition(layoutTransition); chating_view.addView(tipsFloatView); } }, 500); }
Example 15
Source File: MDA_PageListLayout.java From DraggedViewPager with Apache License 2.0 | 5 votes |
private void init() { //设置布局方向 setOrientation(VERTICAL); //设置动画 LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, null); layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, null); setLayoutTransition(layoutTransition); }
Example 16
Source File: CardStreamLinearLayout.java From android-BatchStepSensor with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); Log.d(TAG, "onLayout: " + changed); if( changed && !mLayouted ){ mLayouted = true; ObjectAnimator animator; LayoutTransition layoutTransition = new LayoutTransition(); animator = mAnimators.getDisappearingAnimator(getContext()); layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, animator); animator = mAnimators.getAppearingAnimator(getContext()); layoutTransition.setAnimator(LayoutTransition.APPEARING, animator); layoutTransition.addTransitionListener(mTransitionListener); if( animator != null ) layoutTransition.setDuration(animator.getDuration()); setLayoutTransition(layoutTransition); if( mShowInitialAnimation ) runInitialAnimations(); if (mFirstVisibleCardTag != null) { scrollToCard(mFirstVisibleCardTag); mFirstVisibleCardTag = null; } } }
Example 17
Source File: PbChatActivity.java From imsdk-android with MIT License | 4 votes |
/** * at消息提示 */ @SuppressLint("ObjectAnimatorBinding") public void showAtmsgView() { if (isFinishing()) { return; } ImageView tipImage = new ImageView(PbChatActivity.this); tipImage.setImageResource(R.drawable.atom_ui_chat_unread_tip); final TextView textView = new TextView(PbChatActivity.this); int padding = Utils.dipToPixels(PbChatActivity.this, 4); int size = Utils.dipToPixels(PbChatActivity.this, 30); int topMargin = Utils.dipToPixels(PbChatActivity.this, 70); final LinearLayout linearLayout = new LinearLayout(PbChatActivity.this); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); linearLayout.setBackgroundResource(R.drawable.atom_ui_float_tab); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, size); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.setMargins(0, topMargin, 0, 0); linearLayout.setPadding(padding * 2, padding, padding * 2, padding); linearLayout.setLayoutParams(layoutParams); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); String msg = MessageFormat.format(getString(R.string.atom_ui_tip_somebody_at_you), atMsgIndexs.size()); textView.setText(msg); textView.setTextColor(Color.parseColor("#EB524A")); textView.setPadding(padding * 2, 0, 0, 0); textView.setOnClickListener(v -> { chat_region.getRefreshableView().smoothScrollToPosition(atMsgIndex); clearAtmsgTip(); }); linearLayout.addView(tipImage); linearLayout.addView(textView); linearLayout.setTag(TAG_ATMSG_VIEW); final LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(this, "scaleX", 0, 1)); getHandler().postDelayed(() -> { if (!isFinishing()) { chating_view.setLayoutTransition(layoutTransition); chating_view.addView(linearLayout); } }, 500); }
Example 18
Source File: LayoutAnimActivity.java From AndroidStudyDemo with GNU General Public License v2.0 | 4 votes |
private void setupTransition(LayoutTransition transition) { // 首先,把多选按钮全都获取一遍 CheckBox customAnimCB = (CheckBox) findViewById(R.id.cb_customanim); CheckBox appearingCB = (CheckBox) findViewById(R.id.cb_appearing); CheckBox disappearingCB = (CheckBox) findViewById(R.id.cb_disappearing); CheckBox changingAppearingCB = (CheckBox) findViewById(R.id.cb_changingAppearing); CheckBox changingDisappearingCB = (CheckBox) findViewById(R.id.cb_changingDisappearing); // 然后,根据多选按钮的选择状态来setAnimator // 解释一下第一个: // mAppearingCB.isChecked()? // / \ // true false -> transition.setAnimator(LayoutTransition.APPEARING,null) // | // mCustomAnimCB.isChecked() ? // / \ // true false -> // transition.setAnimator(LayoutTransition.APPEARING,mDefaultAppearingAnim) // |-->transition.setAnimator(LayoutTransition.APPEARING,mCustomAppearingAnim) transition.setAnimator(LayoutTransition.APPEARING, appearingCB .isChecked() ? (customAnimCB.isChecked() ? mCustomAppearingAnim : mDefaultAppearingAnim) : null); // 后面三个依次类推 transition .setAnimator( LayoutTransition.DISAPPEARING, disappearingCB.isChecked() ? (customAnimCB.isChecked() ? mCustomDisappearingAnim : mDefaultDisappearingAnim) : null); transition .setAnimator( LayoutTransition.CHANGE_APPEARING, changingAppearingCB.isChecked() ? (customAnimCB .isChecked() ? mCustomChangingAppearingAnim : mDefaultChangingAppearingAnim) : null); transition .setAnimator( LayoutTransition.CHANGE_DISAPPEARING, changingDisappearingCB.isChecked() ? (customAnimCB .isChecked() ? mCustomChangingDisappearingAnim : mDefaultChangingDisappearingAnim) : null); }
Example 19
Source File: PbChatActivity.java From imsdk-android with MIT License | 4 votes |
/** * 未读消息数提示 * isNew 是否是新消息 */ @SuppressLint("ObjectAnimatorBinding") public void showUnreadView(int unread) { if (unread <= 0 || isFinishing()) { return; } ImageView tipImage = new ImageView(PbChatActivity.this); tipImage.setImageResource(R.drawable.atom_ui_chat_unread_tip); final TextView textView = new TextView(PbChatActivity.this); int padding = Utils.dipToPixels(PbChatActivity.this, 4); int size = Utils.dipToPixels(PbChatActivity.this, 30); int topMargin = Utils.dipToPixels(PbChatActivity.this, 30); final LinearLayout linearLayout = new LinearLayout(PbChatActivity.this); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); linearLayout.setBackgroundResource(R.drawable.atom_ui_float_tab); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, size); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.setMargins(0, topMargin, 0, 0); linearLayout.setPadding(padding * 2, padding, padding * 2, padding); linearLayout.setLayoutParams(layoutParams); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); textView.setTextColor(Color.parseColor("#666666")); String msg = unread + (String) getText(R.string.atom_ui_tip_unread_message); textView.setText(msg); textView.setPadding(padding*2, 0, 0, 0); textView.setOnClickListener((view) -> { chat_region.getRefreshableView().smoothScrollToPosition(pbChatViewAdapter.getCount() - unreadMsgCount.intValue() - 1); clearUnread(); }); linearLayout.addView(tipImage); linearLayout.addView(textView); linearLayout.setTag(TAG_UNREAD_VIEW); final LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(this, "scaleX", 0, 1)); getHandler().postDelayed(() -> { if(!isFinishing()){ chating_view.setLayoutTransition(layoutTransition); chating_view.addView(linearLayout); } }, 500); }
Example 20
Source File: LayoutAnimations.java From AnimationApiDemos with Apache License 2.0 | 4 votes |
private void setupTransition(LayoutTransition transition) { // 首先,把多选按钮全都获取一遍 CheckBox customAnimCB = (CheckBox) findViewById(R.id.customAnimCB); CheckBox appearingCB = (CheckBox) findViewById(R.id.appearingCB); CheckBox disappearingCB = (CheckBox) findViewById(R.id.disappearingCB); CheckBox changingAppearingCB = (CheckBox) findViewById(R.id.changingAppearingCB); CheckBox changingDisappearingCB = (CheckBox) findViewById(R.id.changingDisappearingCB); // 然后,根据多选按钮的选择状态来setAnimator // 解释一下第一个: // appearingCB.isChecked()? // / \ // true false -> transition.setAnimator(LayoutTransition.APPEARING,null) // | // customAnimCB.isChecked() ? // / \ // true false -> // transition.setAnimator(LayoutTransition.APPEARING,defaultAppearingAnim) // |-->transition.setAnimator(LayoutTransition.APPEARING,customAppearingAnim) transition.setAnimator(LayoutTransition.APPEARING, appearingCB .isChecked() ? (customAnimCB.isChecked() ? customAppearingAnim : defaultAppearingAnim) : null); // 后面三个依次类推 transition .setAnimator( LayoutTransition.DISAPPEARING, disappearingCB.isChecked() ? (customAnimCB.isChecked() ? customDisappearingAnim : defaultDisappearingAnim) : null); transition .setAnimator( LayoutTransition.CHANGE_APPEARING, changingAppearingCB.isChecked() ? (customAnimCB .isChecked() ? customChangingAppearingAnim : defaultChangingAppearingAnim) : null); transition .setAnimator( LayoutTransition.CHANGE_DISAPPEARING, changingDisappearingCB.isChecked() ? (customAnimCB .isChecked() ? customChangingDisappearingAnim : defaultChangingDisappearingAnim) : null); }