| 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.widget.Button; |
| 23 |
|
| 24 |
|
| 25 |
public class OverlayTest extends Activity { |
| 26 |
|
| 27 |
ViewGroup mContainer; |
| 28 |
ViewGroup mRoot; |
| 29 |
|
| 30 |
@Override |
| 31 |
protected void onCreate(Bundle savedInstanceState) { |
| 32 |
super.onCreate(savedInstanceState); |
| 33 |
setContentView(R.layout.overlay_test); |
| 34 |
|
| 35 |
mContainer = findViewById(R.id.container); |
| 36 |
mRoot = (ViewGroup) mContainer.getParent(); |
| 37 |
} |
| 38 |
|
| 39 |
public void onClick(View view) { |
| 40 |
final Button fadingButton = findViewById(R.id.fadingButton); |
| 41 |
if (fadingButton != null) { |
| 42 |
mContainer.removeView(fadingButton); |
| 43 |
mRoot.getOverlay().add(fadingButton); |
| 44 |
fadingButton.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() { |
| 45 |
@Override |
| 46 |
public void run() { |
| 47 |
fadingButton.setAlpha(1); |
| 48 |
mRoot.getOverlay().remove(fadingButton); |
| 49 |
mContainer.addView(fadingButton); |
| 50 |
} |
| 51 |
}); |
| 52 |
} |
| 53 |
} |
| 54 |
} |