use of android.widget.GridLayout in project android_frameworks_base by DirtyUnicorns.
the class BiDiTestGridLayoutCodeLtr method create.
public static View create(Context context) {
GridLayout layout = new GridLayout(context);
layout.setUseDefaultMargins(true);
layout.setAlignmentMode(ALIGN_BOUNDS);
layout.setRowOrderPreserved(false);
layout.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
Spec row1 = spec(0);
Spec row2 = spec(1);
Spec row3 = spec(2, BASELINE);
Spec row4 = spec(3, BASELINE);
// allow the last two rows to overlap the middle two
Spec row5 = spec(2, 3, FILL);
Spec row6 = spec(5);
Spec row7 = spec(6);
Spec col1a = spec(0, 4, CENTER);
Spec col1b = spec(0, 4, LEFT);
Spec col1c = spec(0, RIGHT);
Spec col2 = spec(1, START);
Spec col3 = spec(2, FILL);
Spec col4a = spec(3);
Spec col4b = spec(3, FILL);
{
TextView c = new TextView(context);
c.setTextSize(32);
c.setText("Email setup");
layout.addView(c, new GridLayout.LayoutParams(row1, col1a));
}
{
TextView c = new TextView(context);
c.setTextSize(16);
c.setText("You can configure email in just a few steps:");
layout.addView(c, new GridLayout.LayoutParams(row2, col1b));
}
{
TextView c = new TextView(context);
c.setText("Email address:");
layout.addView(c, new GridLayout.LayoutParams(row3, col1c));
}
{
EditText c = new EditText(context);
c.setEms(10);
c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
layout.addView(c, new GridLayout.LayoutParams(row3, col2));
}
{
TextView c = new TextView(context);
c.setText("Password:");
layout.addView(c, new GridLayout.LayoutParams(row4, col1c));
}
{
TextView c = new EditText(context);
c.setEms(8);
c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
layout.addView(c, new GridLayout.LayoutParams(row4, col2));
}
{
Space c = new Space(context);
layout.addView(c, new GridLayout.LayoutParams(row5, col3));
}
{
Button c = new Button(context);
c.setText("Manual setup");
layout.addView(c, new GridLayout.LayoutParams(row6, col4a));
}
{
Button c = new Button(context);
c.setText("Next");
layout.addView(c, new GridLayout.LayoutParams(row7, col4b));
}
return layout;
}
use of android.widget.GridLayout in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class VectorDrawablePerformance 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);
Resources res = this.getResources();
container.setBackgroundColor(0xFF888888);
VectorDrawable[] d = new VectorDrawable[icon.length];
long time = android.os.SystemClock.elapsedRealtimeNanos();
for (int i = 0; i < icon.length; i++) {
d[i] = create(res, icon[i]);
}
time = android.os.SystemClock.elapsedRealtimeNanos() - time;
TextView t = new TextView(this);
DecimalFormat df = new DecimalFormat("#.##");
t.setText("avgL=" + df.format(time / (icon.length * 1000000.)) + " ms");
container.addView(t);
time = android.os.SystemClock.elapsedRealtimeNanos();
for (int i = 0; i < icon.length; i++) {
Button button = new Button(this);
button.setWidth(200);
button.setBackgroundResource(icon[i]);
container.addView(button);
}
setContentView(scrollView);
time = android.os.SystemClock.elapsedRealtimeNanos() - time;
t = new TextView(this);
t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms");
container.addView(t);
}
use of android.widget.GridLayout in project android_frameworks_base by DirtyUnicorns.
the class AnimatedStateVectorDrawableTest 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(2);
for (int i = 0; i < icon.length; i++) {
CheckBox button = new CheckBox(this);
button.setWidth(400);
button.setHeight(400);
button.setBackgroundResource(icon[i]);
container.addView(button);
}
setContentView(scrollView);
}
use of android.widget.GridLayout in project android_frameworks_base by DirtyUnicorns.
the class AnimatedVectorDrawableDupPerf 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(5);
Resources res = this.getResources();
container.setBackgroundColor(0xFF888888);
AnimatedVectorDrawable[] d = new AnimatedVectorDrawable[icon.length];
long time = android.os.SystemClock.elapsedRealtimeNanos();
for (int i = 0; i < icon.length; i++) {
d[i] = create(res, icon[i]);
}
time = android.os.SystemClock.elapsedRealtimeNanos() - time;
TextView t = new TextView(this);
DecimalFormat df = new DecimalFormat("#.##");
t.setText("avgL=" + df.format(time / (icon.length * 1000000.)) + " ms");
container.addView(t);
time = android.os.SystemClock.elapsedRealtimeNanos();
for (int i = 0; i < icon.length; i++) {
Button button = new Button(this);
button.setWidth(200);
button.setBackgroundResource(icon[i]);
container.addView(button);
}
setContentView(scrollView);
time = android.os.SystemClock.elapsedRealtimeNanos() - time;
t = new TextView(this);
t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms");
container.addView(t);
}
Aggregations