use of android.widget.GridLayout in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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);
}
use of android.widget.GridLayout in project PhotoNoter by yydcdut.
the class ColorChooserDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View v = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_color_chooser, null);
AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.note_dialog).setTitle(R.string.color_chooser).setCancelable(true).setView(v).create();
final TypedArray ta = getActivity().getResources().obtainTypedArray(R.array.colors);
mColors = new int[ta.length()];
for (int i = 0; i < ta.length(); i++) {
mColors[i] = ta.getColor(i, 0);
}
ta.recycle();
final GridLayout list = (GridLayout) v.findViewById(R.id.grid);
final int preselect = getArguments().getInt("preselect", -1);
for (int i = 0; i < mColors.length; i++) {
FrameLayout child = (FrameLayout) list.getChildAt(i);
child.setTag(i);
child.setOnClickListener(this);
child.getChildAt(0).setVisibility(preselect == i ? View.VISIBLE : View.GONE);
Drawable selector = createSelector(mColors[i]);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[][] states = new int[][] { new int[] { -android.R.attr.state_pressed }, new int[] { android.R.attr.state_pressed } };
int[] colors = new int[] { shiftColor(mColors[i]), mColors[i] };
ColorStateList rippleColors = new ColorStateList(states, colors);
setBackgroundCompat(child, new RippleDrawable(rippleColors, selector, null));
} else {
setBackgroundCompat(child, selector);
}
}
return dialog;
}
use of android.widget.GridLayout in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
the class GridLayoutTest method create.
public ViewGroup create(Context context) {
GridLayout container = new GridLayout(context);
container.setOrientation(VERTICAL);
for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
int va = VERTICAL_ALIGNMENTS[i];
for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
int ha = HORIZONTAL_ALIGNMENTS[j];
Spec rowSpec = spec(UNDEFINED, null);
Spec colSpec = spec(UNDEFINED, null);
GridLayout.LayoutParams lp = new GridLayout.LayoutParams(rowSpec, colSpec);
//GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.setGravity(va | ha);
View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
container.addView(v, lp);
}
}
return container;
}
Aggregations