1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.transitiontests; 17 18 import android.app.Activity; 19 import android.os.Bundle; 20 import android.transition.ChangeBounds; 21 import android.view.View; 22 import android.view.ViewGroup; 23 import android.transition.Scene; 24 import android.widget.Button; 25 import android.transition.Fade; 26 import android.transition.ChangeText; 27 import android.transition.TransitionSet; 28 import android.transition.TransitionManager; 29 30 public class ClippingText extends Activity { 31 32 Button mRemovingButton, mInvisibleButton, mGoneButton; 33 Scene mScene1, mScene2; 34 ViewGroup mSceneRoot; 35 // static Fade sFade = new Fade(R.id.removingButton, R.id.invisibleButton, R.id.goneButton); 36 Fade fader; 37 TransitionSet mChanger; 38 Scene mCurrentScene; 39 40 @Override 41 public void onCreate(Bundle savedInstanceState) { 42 super.onCreate(savedInstanceState); 43 setContentView(R.layout.clipping_text_1); 44 45 View container = (View) findViewById(R.id.container); 46 mSceneRoot = (ViewGroup) container.getParent(); 47 48 mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_1, this); 49 mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.clipping_text_2, this); 50 51 mChanger = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER); 52 ChangeBounds changeBounds = new ChangeBounds(); 53 changeBounds.setResizeClip(true); 54 mChanger.addTransition(changeBounds).addTransition(new ChangeText()); 55 56 mCurrentScene = mScene1; 57 } 58 59 public void sendMessage(View view) { 60 if (mCurrentScene == mScene1) { 61 TransitionManager.go(mScene2, mChanger); 62 mCurrentScene = mScene2; 63 } else { 64 TransitionManager.go(mScene1, mChanger); 65 mCurrentScene = mScene1; 66 } 67 } 68 } 69