Debian Codegraph @

tests/VectorDrawableTest/src/com/android/test/dynamic/ScaleDrawableTests.java

raw symbols SCIP
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.os.Bundle;
18 import android.view.ViewGroup.LayoutParams;
19 import android.widget.ImageView;
20 import android.widget.TextView;
21 import android.widget.GridLayout;
22 import android.widget.ScrollView;
23
24 @SuppressWarnings({"UnusedDeclaration"})
25 public class ScaleDrawableTests extends Activity {
26 private static final String LOGCAT = "VectorDrawable1";
27
28 private String[] scaleTypes = {
29 "MATRIX (0)",
30 "FIT_XY (1)",
31 "FIT_START (2)",
32 "FIT_CENTER (3)",
33 "FIT_END (4)",
34 "CENTER (5)",
35 "CENTER_CROP (6)",
36 "CENTER_INSIDE (7)"
37 };
38
39 protected int icon = R.drawable.bitmap_drawable01;
40 protected int vector_icon = R.drawable.vector_drawable16;
41 protected int animated_vector_icon = R.drawable.ic_hourglass_animation;
42
43 @Override
44 protected void onCreate(Bundle savedInstanceState) {
45 super.onCreate(savedInstanceState);
46 ScrollView scrollView = new ScrollView(this);
47 GridLayout container = new GridLayout(this);
48 scrollView.addView(container);
49 container.setColumnCount(4);
50 container.setBackgroundColor(0xFF888888);
51
52 LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
53 params.width = 300;
54 params.height = 200;
55
56 for (int i = 0; i < scaleTypes.length; i++) {
57 TextView t = new TextView(this);
58 t.setText(scaleTypes[i]);
59 container.addView(t);
60
61 ImageView.ScaleType scaleType = ImageView.ScaleType.values()[i];
62
63 ImageView png_view = new ImageView(this);
64 png_view.setLayoutParams(params);
65 png_view.setScaleType(scaleType);
66 png_view.setImageResource(icon);
67 container.addView(png_view);
68
69 ImageView view = new ImageView(this);
70 view.setLayoutParams(params);
71 view.setScaleType(scaleType);
72 view.setImageResource(vector_icon);
73 container.addView(view);
74
75 ImageView avd_view = new ImageView(this);
76 avd_view.setLayoutParams(params);
77 avd_view.setScaleType(scaleType);
78 avd_view.setImageResource(animated_vector_icon);
79 container.addView(avd_view);
80
81 }
82
83 setContentView(scrollView);
84 }
85 }