use of android.widget.GridLayout in project android_frameworks_base by crdroidandroid.
the class AnimatedVectorDrawableTest method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
final int[] layerTypes = { View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE };
final boolean[] forceOnUi = { false, true };
super.onCreate(savedInstanceState);
ScrollView scrollView = new ScrollView(this);
GridLayout container = new GridLayout(this);
scrollView.addView(container);
container.setColumnCount(layerTypes.length * forceOnUi.length);
for (int j = 0; j < layerTypes.length; j++) {
for (int k = 0; k < forceOnUi.length; k++) {
TextView textView = new TextView(this);
String category = "Layer:" + (layerTypes[j] == View.LAYER_TYPE_SOFTWARE ? "SW" : "HW") + (forceOnUi[k] == true ? ",forceUI" : "");
textView.setText(category);
container.addView(textView);
}
}
for (int i = 0; i < icon.length; i++) {
for (int j = 0; j < layerTypes.length; j++) {
for (int k = 0; k < forceOnUi.length; k++) {
Button button = new Button(this);
button.setWidth(300);
button.setHeight(300);
button.setLayerType(layerTypes[j], null);
button.setBackgroundResource(icon[i]);
AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
if (forceOnUi[k] == true) {
d.forceAnimationOnUI();
}
d.registerAnimationCallback(new Animatable2.AnimationCallback() {
@Override
public void onAnimationStart(Drawable drawable) {
Log.v(LOGCAT, "Animator start");
}
@Override
public void onAnimationEnd(Drawable drawable) {
Log.v(LOGCAT, "Animator end");
}
});
container.addView(button);
button.setOnClickListener(this);
}
}
}
setContentView(scrollView);
}
use of android.widget.GridLayout in project android_frameworks_base by crdroidandroid.
the class ScaleDrawableTests method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView scrollView = new ScrollView(this);
GridLayout container = new GridLayout(this);
scrollView.addView(container);
container.setColumnCount(4);
container.setBackgroundColor(0xFF888888);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
params.width = 300;
params.height = 200;
for (int i = 0; i < scaleTypes.length; i++) {
TextView t = new TextView(this);
t.setText(scaleTypes[i]);
container.addView(t);
ImageView.ScaleType scaleType = ImageView.ScaleType.values()[i];
ImageView png_view = new ImageView(this);
png_view.setLayoutParams(params);
png_view.setScaleType(scaleType);
png_view.setImageResource(icon);
container.addView(png_view);
ImageView view = new ImageView(this);
view.setLayoutParams(params);
view.setScaleType(scaleType);
view.setImageResource(vector_icon);
container.addView(view);
ImageView avd_view = new ImageView(this);
avd_view.setLayoutParams(params);
avd_view.setScaleType(scaleType);
avd_view.setImageResource(animated_vector_icon);
container.addView(avd_view);
}
setContentView(scrollView);
}
use of android.widget.GridLayout in project android_frameworks_base by crdroidandroid.
the class VectorCheckbox method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GridLayout container = new GridLayout(this);
container.setColumnCount(5);
container.setBackgroundColor(0xFF888888);
final Button[] bArray = new Button[icon.length];
for (int i = 0; i < icon.length; i++) {
CheckBox checkBox = new CheckBox(this);
bArray[i] = checkBox;
checkBox.setWidth(200);
checkBox.setButtonDrawable(icon[i]);
container.addView(checkBox);
}
setContentView(container);
}
use of android.widget.GridLayout in project android_frameworks_base by crdroidandroid.
the class VectorDrawable01 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GridLayout container = new GridLayout(this);
container.setColumnCount(5);
container.setBackgroundColor(0xFF888888);
final Button[] bArray = new Button[icon.length];
CheckBox toggle = new CheckBox(this);
toggle.setText("Toggle");
toggle.setChecked(true);
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ViewGroup vg = (ViewGroup) buttonView.getParent();
for (int i = 0, count = vg.getChildCount(); i < count; i++) {
View child = vg.getChildAt(i);
if (child != buttonView) {
child.setEnabled(isChecked);
}
}
}
});
container.addView(toggle);
for (int i = 0; i < icon.length; i++) {
Button button = new Button(this);
bArray[i] = button;
button.setWidth(200);
button.setBackgroundResource(icon[i]);
container.addView(button);
VectorDrawable vd = (VectorDrawable) button.getBackground();
vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
}
setContentView(container);
}
use of android.widget.GridLayout in project android_frameworks_base by crdroidandroid.
the class ActivityTransition method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
setContentView(R.layout.activity_transition);
setupHero();
// Ensure that all images are visible regardless of orientation.
GridLayout gridLayout = (GridLayout) findViewById(R.id.transition_grid_layout);
boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
gridLayout.setRowCount(isPortrait ? 4 : 2);
gridLayout.setColumnCount(isPortrait ? 2 : 4);
}
Aggregations