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 */
16package com.android.transitiontests;
17
18import android.app.Activity;
19import android.os.Bundle;
20import android.view.View;
21import android.view.ViewGroup;
22import android.widget.Button;
23
24
25public 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 = (ViewGroup) findViewById(R.id.container);
36        mRoot = (ViewGroup) mContainer.getParent();
37    }
38
39    public void onClick(View view) {
40        final Button fadingButton = (Button) 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}
55