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 package com.android.test.dynamic;
     15 
     16 import android.app.Activity;
     17 import android.graphics.drawable.VectorDrawable;
     18 import android.os.Bundle;
     19 import android.util.Log;
     20 import android.view.View;
     21 import android.widget.Button;
     22 import android.widget.GridLayout;
     23 
     24 @SuppressWarnings({"UnusedDeclaration"})
     25 public class VectorDrawable01 extends Activity {
     26     private static final String LOGCAT = "VectorDrawable1";
     27     int[] icon = {
     28             R.drawable.vector_drawable01,
     29             R.drawable.vector_drawable02,
     30             R.drawable.vector_drawable03,
     31             R.drawable.vector_drawable04,
     32             R.drawable.vector_drawable05,
     33             R.drawable.vector_drawable06,
     34             R.drawable.vector_drawable07,
     35             R.drawable.vector_drawable08,
     36             R.drawable.vector_drawable09,
     37             R.drawable.vector_drawable10,
     38             R.drawable.vector_drawable11,
     39             R.drawable.vector_drawable12,
     40             R.drawable.vector_drawable13,
     41             R.drawable.vector_drawable14,
     42             R.drawable.vector_drawable15,
     43             R.drawable.vector_drawable16,
     44             R.drawable.vector_drawable17,
     45             R.drawable.vector_drawable18,
     46             R.drawable.vector_drawable19,
     47             R.drawable.vector_drawable20
     48     };
     49 
     50     @Override
     51     protected void onCreate(Bundle savedInstanceState) {
     52         super.onCreate(savedInstanceState);
     53         GridLayout container = new GridLayout(this);
     54         container.setColumnCount(5);
     55         container.setBackgroundColor(0xFF888888);
     56         final Button []bArray = new Button[icon.length];
     57 
     58         for (int i = 0; i < icon.length; i++) {
     59             Button button = new Button(this);
     60             bArray[i] = button;
     61             button.setWidth(200);
     62             button.setBackgroundResource(icon[i]);
     63             container.addView(button);
     64             VectorDrawable vd = (VectorDrawable) button.getBackground();
     65             vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
     66         }
     67 
     68         setContentView(container);
     69 
     70     }
     71 
     72 }
     73