AnimatedVectorDrawableTest.java revision 5eb5cde467081d1af628e5463ba55f110265a86f
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 15package com.android.test.dynamic; 16 17import android.app.Activity; 18import android.graphics.drawable.AnimatedVectorDrawable; 19import android.os.Bundle; 20import android.view.View; 21import android.widget.Button; 22import android.widget.GridLayout; 23import android.widget.ScrollView; 24 25public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener { 26 private static final String LOGCAT = "AnimatedVectorDrawableTest"; 27 28 protected int[] icon = { 29 R.drawable.animation_vector_linear_progress_bar, 30 R.drawable.animation_vector_drawable_grouping_1, 31 R.drawable.animation_vector_progress_bar, 32 R.drawable.animation_vector_drawable_favorite, 33 R.drawable.animation_vector_drawable01, 34 }; 35 36 @Override 37 protected void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 40 ScrollView scrollView = new ScrollView(this); 41 GridLayout container = new GridLayout(this); 42 scrollView.addView(container); 43 container.setColumnCount(1); 44 45 for (int i = 0; i < icon.length; i++) { 46 Button button = new Button(this); 47 button.setWidth(400); 48 button.setHeight(400); 49 button.setBackgroundResource(icon[i]); 50 container.addView(button); 51 button.setOnClickListener(this); 52 } 53 54 setContentView(scrollView); 55 } 56 57 @Override 58 public void onClick(View v) { 59 AnimatedVectorDrawable d = (AnimatedVectorDrawable) v.getBackground(); 60 d.start(); 61 } 62} 63