| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package com.android.transitiontests; |
| 17 |
|
| 18 |
import android.app.Activity; |
| 19 |
import android.os.Bundle; |
| 20 |
import android.view.View; |
| 21 |
import android.view.ViewGroup; |
| 22 |
import android.transition.ChangeBounds; |
| 23 |
import android.transition.TransitionManager; |
| 24 |
import android.widget.Button; |
| 25 |
|
| 26 |
import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT; |
| 27 |
import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT; |
| 28 |
import static android.widget.RelativeLayout.LayoutParams; |
| 29 |
|
| 30 |
public class InstanceTargets extends Activity { |
| 31 |
|
| 32 |
ViewGroup mSceneRoot; |
| 33 |
static int mCurrentScene; |
| 34 |
|
| 35 |
@Override |
| 36 |
public void onCreate(Bundle savedInstanceState) { |
| 37 |
super.onCreate(savedInstanceState); |
| 38 |
setContentView(R.layout.instance_targets); |
| 39 |
|
| 40 |
View container = findViewById(R.id.container); |
| 41 |
mSceneRoot = (ViewGroup) container; |
| 42 |
} |
| 43 |
|
| 44 |
public void sendMessage(final View view) { |
| 45 |
TransitionManager.beginDelayedTransition(mSceneRoot, new ChangeBounds().addTarget(view)); |
| 46 |
for (int i = 0; i < mSceneRoot.getChildCount(); ++i) { |
| 47 |
Button button = (Button) mSceneRoot.getChildAt(i); |
| 48 |
LayoutParams params = (LayoutParams) button.getLayoutParams(); |
| 49 |
int rules[] = params.getRules(); |
| 50 |
if (rules[ALIGN_PARENT_RIGHT] != 0) { |
| 51 |
params.removeRule(ALIGN_PARENT_RIGHT); |
| 52 |
params.addRule(ALIGN_PARENT_LEFT); |
| 53 |
} else { |
| 54 |
params.removeRule(ALIGN_PARENT_LEFT); |
| 55 |
params.addRule(ALIGN_PARENT_RIGHT); |
| 56 |
} |
| 57 |
button.setLayoutParams(params); |
| 58 |
} |
| 59 |
} |
| 60 |
} |