Home | History | Annotate | Download | only in dynamic
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
      5  * in compliance with the License. You may obtain a copy of the License at
      6  *
      7  * http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the License
     10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
     11  * or implied. See the License for the specific language governing permissions and limitations under
     12  * the License.
     13  */
     14 
     15 package com.android.test.dynamic;
     16 
     17 import android.app.Activity;
     18 import android.graphics.drawable.AnimatedVectorDrawable;
     19 import android.os.Bundle;
     20 import android.view.View;
     21 import android.widget.Button;
     22 import android.widget.GridLayout;
     23 import android.widget.ScrollView;
     24 
     25 public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener {
     26     private static final String LOGCAT = "AnimatedVectorDrawableTest";
     27 
     28     protected int[] icon = {
     29             R.drawable.ic_rotate_2_portrait_v2_animation,
     30             R.drawable.ic_signal_airplane_v2_animation,
     31             R.drawable.ic_hourglass_animation,
     32             R.drawable.animation_vector_linear_progress_bar,
     33             R.drawable.animation_vector_drawable_grouping_1,
     34             R.drawable.animation_vector_progress_bar,
     35             R.drawable.animation_vector_drawable_favorite,
     36             R.drawable.animation_vector_drawable01,
     37             // Duplicate to test constant state.
     38             R.drawable.animation_vector_drawable01,
     39     };
     40 
     41     @Override
     42     protected void onCreate(Bundle savedInstanceState) {
     43         super.onCreate(savedInstanceState);
     44 
     45         ScrollView scrollView = new ScrollView(this);
     46         GridLayout container = new GridLayout(this);
     47         scrollView.addView(container);
     48         container.setColumnCount(1);
     49 
     50         for (int i = 0; i < icon.length; i++) {
     51             Button button = new Button(this);
     52             button.setWidth(400);
     53             button.setHeight(400);
     54             button.setBackgroundResource(icon[i]);
     55             container.addView(button);
     56             button.setOnClickListener(this);
     57         }
     58 
     59         setContentView(scrollView);
     60     }
     61 
     62     @Override
     63     public void onClick(View v) {
     64         AnimatedVectorDrawable d = (AnimatedVectorDrawable) v.getBackground();
     65         d.start();
     66     }
     67 }
     68