private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) { // The icon has a pre-defined width. ImageView optionIcon = new ImageView(parent.getContext()); optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); optionIcon.setBackgroundResource(R.drawable.payments_ui_logo_bg); optionIcon.setImageDrawable(mOption.getDrawableIcon()); optionIcon.setMaxWidth(mIconMaxWidth); // Place option icon at column three if no edit icon. int columnStart = editIconExists ? 2 : 3; GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams( GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(columnStart, 1)); iconParams.topMargin = mVerticalMargin; parent.addView(optionIcon, iconParams); optionIcon.setOnClickListener(OptionSection.this); return optionIcon; }
private void addStripes() { GridLayout gridLayout=new GridLayout(this); RelativeLayout.LayoutParams gl=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); gridLayout.setColumnCount(gridColumnCount); gridLayout.setLayoutParams(gl); parentLayout.addView(gridLayout); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(deviceWidth/2,deviceHeight/3); Log.i(Tag,"addStripes called"); for (int i = 0; i < stripeCount; i++) { stripe[i] = new Stripes(this,i); stripe[i].setLayoutParams(layoutParams); gridLayout.addView(stripe[i]); } addColors(); }
@Override protected void createMainSectionContent(LinearLayout mainSectionLayout) { Context context = mainSectionLayout.getContext(); // Add a label that will be used to indicate that the total cart price has been updated. addUpdateText(mainSectionLayout); // The breakdown is represented by an end-aligned GridLayout that takes up only as much // space as it needs. The GridLayout ensures a consistent margin between the columns. mBreakdownLayout = new GridLayout(context); mBreakdownLayout.setColumnCount(2); LayoutParams breakdownParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); breakdownParams.gravity = Gravity.END; mainSectionLayout.addView(mBreakdownLayout, breakdownParams); }
public void repopulate() { final List<ComponentName> quickRowOrder = db().getAppCategoryOrder(QUICK_ROW_CAT); mQuickRow.postDelayed(new Runnable() { @Override public void run() { mQuickRow.removeAllViews(); for (ComponentName actvname : quickRowOrder) { AppLauncher app = db().getApp(actvname); if (!appAlreadyHere(app)) { ViewGroup item = mMainActivity.getLauncherView(app, true); if (item != null) { GridLayout.LayoutParams lp = new GridLayout.LayoutParams(); lp.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, GridLayout.TOP); mQuickRow.addView(item, lp); } } } } }, 400); }
private void makeColorPresetButton(int color) { FrameLayout outframe = new FrameLayout(getContext()); outframe.setBackgroundColor(Color.BLACK); outframe.setPadding(6,6,6,6); FrameLayout frame = new FrameLayout(getContext()); //frame.setBackgroundColor(Color.BLACK); frame.setBackgroundResource(R.drawable.transparentgrid); TextView c = new TextView(getContext()); c.setText(" "); c.setTextSize(22); c.setBackgroundColor(color); // if (color==Color.TRANSPARENT) { // c.setBackgroundResource(R.drawable.transparentgrid); // } c.setTag(color); c.setClickable(true); c.setOnClickListener(setColorListener); frame.addView(c); GridLayout.LayoutParams lp = new GridLayout.LayoutParams(); lp.setMargins(24, 16, 24, 16); outframe.setPadding(6,6,6,6); outframe.addView(frame); colorPresets.addView(outframe, lp); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chain_explorer); blocksList = findViewById(R.id.blocks_list); // Create a progress bar to display while the list loads ProgressBar progressBar = new ProgressBar(this); progressBar.setLayoutParams(new LinearLayout.LayoutParams(GridLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, CENTER)); progressBar.setIndeterminate(true); blocksList.setEmptyView(progressBar); // Must add the progress bar to the root of the layout ViewGroup root = findViewById(android.R.id.content); root.addView(progressBar); init(); }
public ColorGridView(@NonNull final Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { super(context, attrs, defStyleAttr); setWillNotDraw(false); setRowCount(ROWS); setColumnCount(COLS); for (int row = 0; row < ROWS; row++) { Spec rowSpec = spec(row); for (int col = 0; col < COLS; col++) { Spec colSpec = spec(col); LayoutParams params = new GridLayout.LayoutParams(rowSpec, colSpec); params.width = 150; params.height = 150; View view = createView(context); addView(view, params); } } }
public ServerSettingsClass(Activity activity, String TAG, MainActivity.ServiceControl serviceControl, int extendingSpeed) { this.TAG = TAG; this.activity = activity; this.extendingSpeed = extendingSpeed; this.serviceControl = serviceControl; settingsInner = (GridLayout) activity.findViewById(R.id.serverSettingsInner); settingsHead1 = (TextView) activity.findViewById(R.id.serverSettingsHead1); settingsHead2 = (TextView) activity.findViewById(R.id.serverSettingsHead2); showCurrentServerTextView = (TextView) activity.findViewById(R.id.showCurrentServerTextView); showCurrentServerStatus = (TextView) activity.findViewById(R.id.showCurrentServerStatus); serverUrlEdit = (TextView) activity.findViewById(R.id.serverUrlEdit); serverCommonSecretEdit = (TextView) activity.findViewById(R.id.serverCommonSecretEdit); serverCertEdit = (TextView) activity.findViewById(R.id.serverCertEdit); setOnClick(); }
public StatusClass(Activity activity, String TAG, MainActivity.ServiceControl serviceControl, int extendingSpeed) { this.TAG = TAG; this.activity = activity; this.serviceControl = serviceControl; this.extendingSpeed = extendingSpeed; statusGrid = (GridLayout) activity.findViewById(R.id.statusGrid); setOnClick(); lastLocationTopPreview = (TextView) activity.findViewById(R.id.lastLocationTopPreview); lastLocationBotPreview = (TextView) activity.findViewById(R.id.lastLocationBotPreview); lastLocationFootPreview = (TextView) activity.findViewById(R.id.lastLocationFootPreview); lastLocationToSendTextView = (TextView) activity.findViewById(R.id.lastLocationToSendTextView); mapOverlay = (FrameLayout) activity.findViewById(R.id.mapOverlay); lastLocationDetails = (LinearLayout) activity.findViewById(R.id.lastLocationDetails); /* Set listener to receive location changes, so we can display them */ serviceControl.setLastLocationListener(new Runnable() { @Override public void run() { loadLastLocation(); } }); loadLastLocation(); }
private void handlePreview(MenuItem item) { if (eventGismo == null) { GridLayout gridLayout = findViewById(R.id.events_placeholder); eventGismo = new EventsGismo(gridLayout, PreferenceManager.getDefaultSharedPreferences(this)); eventGismo.addRecyclerView(); handleRefresh(); } if (!previewOn) { findViewById(R.id.events_placeholder).setVisibility(View.VISIBLE); item.setIcon(getDrawable(R.drawable.action_preview_off_icon)); } else { findViewById(R.id.events_placeholder).setVisibility(View.GONE); item.setIcon(getDrawable(R.drawable.action_preview_on_icon)); } previewOn = !previewOn; }
@Override protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) { GridLayout gridLayout = (GridLayout) param.thisObject; eventsGismo = new EventsGismo(gridLayout, new XSharedPreferences(BuildConfig.APPLICATION_ID)) { @Override public void notifyUpdatedPreferences() { ((XSharedPreferences) preferences).reload(); super.notifyUpdatedPreferences(); } }; eventsGismo.addRecyclerView(); log("Added view to lockscreen"); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.events_update); intentFilter.addAction(Constants.current_event_update); intentFilter.addAction(Constants.looks_update); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); gridLayout.getContext().registerReceiver(updateReceiver, intentFilter); }
@Override protected void onResume() { super.onResume(); GridLayout sortArea = (GridLayout) findViewById(R.id.sort_area); if (isLandscape()) { numcolumns = 6; } else { numcolumns = 3; } sortArea.setColumnCount(numcolumns); //override super class LinearLayout centercol = (LinearLayout) findViewById(R.id.centercol); centercol.setOrientation(LinearLayout.VERTICAL); findViewById(R.id.score_total_correct_area).setVisibility(View.GONE); findViewById(R.id.score_level_percent_area).setVisibility(View.GONE); }
private void initViews() { mGridLayout = (GridLayout) findViewById(R.id.activity_third_gridview); mImageView = (ImageView) findViewById(R.id.activity_third_imageview); mBtnChange = (Button) findViewById(R.id.activity_third_change); mBtnReset = (Button) findViewById(R.id.activity_third_reset); mBitmap = ((BitmapDrawable)mImageView.getDrawable()).getBitmap(); mGridLayout.post(new Runnable() { @Override public void run() { width = mGridLayout.getWidth() / 5; height = mGridLayout.getHeight() / 4; // add edittext addETs(); // init ETText(); initETText(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_map); dynamicGridLayout = (GridLayout) findViewById(R.id.dynamicGridLayout); colors[0] = ContextCompat.getColor(this, R.color.red); colors[1] = ContextCompat.getColor(this, R.color.orange); colors[2] = ContextCompat.getColor(this, R.color.yellow); colors[3] = ContextCompat.getColor(this, R.color.green); colors[4] = ContextCompat.getColor(this, R.color.blue); colors[5] = ContextCompat.getColor(this, R.color.purple); colors[6] = ContextCompat.getColor(this, R.color.pink); colors[7] = ContextCompat.getColor(this, R.color.teal); colors[8] = ContextCompat.getColor(this, R.color.tan); colors[9] = ContextCompat.getColor(this, R.color.gray); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_map); dynamicGridLayout = (GridLayout) findViewById(R.id.dynamicGridLayout); colors[0] = ContextCompat.getColor(this, R.color.red); colors[1] = ContextCompat.getColor(this, R.color.orange); colors[2] = ContextCompat.getColor(this, R.color.yellow); colors[3] = ContextCompat.getColor(this, R.color.green); colors[4] = ContextCompat.getColor(this, R.color.blue); colors[5] = ContextCompat.getColor(this, R.color.purple); colors[6] = ContextCompat.getColor(this, R.color.pink); colors[7] = ContextCompat.getColor(this, R.color.teal); colors[8] = ContextCompat.getColor(this, R.color.tan); colors[9] = ContextCompat.getColor(this, R.color.gray); SharedPreferences myPref = getSharedPreferences("MyPref", MODE_PRIVATE); String map =myPref.getString("memMap", ""); memMap = new Gson().fromJson(map,MapWrapper.class).getMap(); onGenerateClicked(null); }
public void onGenerateClicked(View v) { //now get the maps with default: 7 letters and 3 numbers for easy String letterMap = ALPHABETS; for (int i = 0; i < ALPHABETS.length(); i++) { String curLetter = letterMap.substring(i, i + 1); if (memMap.containsKey(curLetter)){ int curNumber = memMap.get(curLetter); Button button = new Button(this); ViewGroup.MarginLayoutParams marginLayoutParams = new ViewGroup.MarginLayoutParams(dpToPx(48, getResources()), dpToPx(48, getResources())); marginLayoutParams.rightMargin = dpToPx(5, getResources()); marginLayoutParams.bottomMargin = dpToPx(5, getResources()); button.setLayoutParams(new GridLayout.LayoutParams(marginLayoutParams)); button.setBackgroundColor(colors[curNumber]); dynamicGridLayout.addView(button); button.setGravity(Gravity.CENTER); button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); button.setText(curLetter + ":" + curNumber); } } hasGenerated = true; }
private void setUpClsTitle(){ for (int i=0; i<TITLE_DATA.length; ++i){ String content = TITLE_DATA[i]; GridLayout.LayoutParams params = new GridLayout.LayoutParams(); //第一列的时候 if (i == 0){ params.width = mTableDistance; } else { //添加分割线 View divider = getLayoutInflater().inflate(R.layout.grid_title_form,mGlClsTitle,false); mGlClsTitle.addView(divider); params.width = mTableDistance * 2; } params.height = GridLayout.LayoutParams.MATCH_PARENT; TextView textView = new TextView(this); textView.setTextColor(getResources().getColor(R.color.blue)); textView.setText(content); textView.setGravity(Gravity.CENTER); mGlClsTitle.addView(textView,params); } }
public MainViewBinding(View root) { this.root = (ViewGroup) root; toolbar = (Toolbar) root.findViewById(R.id.toolbar); mainViewPager = (ViewPager) root.findViewById(R.id.mainViewPager); fab = (FloatingActionButton) root.findViewById(R.id.fab); cvi = (CutoutViewIndicator) root.findViewById(R.id.cutoutViewIndicator); spacing = (NumberPicker) root.findViewById(R.id.spacingPicker); width = (NumberPicker) root.findViewById(R.id.widthPicker); height = (NumberPicker) root.findViewById(R.id.heightPicker); gridLayout = (GridLayout) root.findViewById(R.id.gridLayout); unifiedButton = (CompoundButton) root.findViewById(R.id.unifiedSwitch); orientationButton = (CompoundButton) root.findViewById(R.id.orientationSwitch); }
private void initView(View view, Bundle savedInstanceState) { layout = new BrowserWeiboMsgLayout(); layout.username = (TextView) view.findViewById(R.id.username); layout.content = (TextView) view.findViewById(R.id.content); layout.recontent = (TextView) view.findViewById(R.id.repost_content); layout.time = (TextView) view.findViewById(R.id.time); layout.location = (TextView) view.findViewById(R.id.location); layout.source = (TextView) view.findViewById(R.id.source); layout.mapView = (ImageView) view.findViewById(R.id.map); layout.comment_count = (TextView) view.findViewById(R.id.comment_count); layout.repost_count = (TextView) view.findViewById(R.id.repost_count); layout.count_layout = view.findViewById(R.id.count_layout); layout.avatar = (ProfileTopAvatarImageView) view.findViewById(R.id.avatar); layout.content_pic = (WeiboDetailImageView) view.findViewById(R.id.content_pic); layout.content_pic_multi = (GridLayout) view.findViewById(R.id.content_pic_multi); layout.repost_pic = (WeiboDetailImageView) view.findViewById(R.id.repost_content_pic); layout.repost_pic_multi = (GridLayout) view.findViewById(R.id.repost_content_pic_multi); layout.repost_layout = (LinearLayout) view.findViewById(R.id.repost_layout); }
protected void interruptPicDownload(GridLayout gridLayout) { for (int i = 0; i < gridLayout.getChildCount(); i++) { ImageView iv = (ImageView) gridLayout.getChildAt(i); if (iv != null) { Drawable drawable = iv.getDrawable(); if (drawable instanceof PictureBitmapDrawable) { PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable; IPictureWorker worker = downloadedDrawable.getBitmapDownloaderTask(); if (worker != null) { ((MyAsyncTask) worker).cancel(true); } iv.setImageDrawable(null); } } } }
protected void interruptPicDownload(GridLayout gridLayout) { for (int i = 0; i < gridLayout.getChildCount(); i++) { ImageView iv = (ImageView) gridLayout.getChildAt(i); if (iv != null) { Drawable drawable = iv.getDrawable(); if (drawable instanceof PictureBitmapDrawable) { PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable; IPictureWorker worker = downloadedDrawable .getBitmapDownloaderTask(); if (worker != null) { ((MyAsyncTask) worker).cancel(true); } iv.setImageDrawable(null); } } } }
public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) return; int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); if (i == 0) view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, GridLayout.LayoutParams.WRAP_CONTENT)); view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); listView.requestLayout(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_property_animation); mBtnXXml = (ImageButton) findViewById(R.id.btn_x_xml); mBtnXCode = (ImageButton) findViewById(R.id.btn_x_code); mGridLayout = (GridLayout) findViewById(R.id.grid); findViewById(R.id.btn_grid).setOnClickListener(this); mBtnXXml.setOnClickListener(this); mBtnXCode.setOnClickListener(this); // GridLayoutにボタンを複数追加 int maxChild = mGridLayout.getRowCount() * mGridLayout.getColumnCount(); for (int i = 0; i < maxChild; i++) { Button button = (Button) getLayoutInflater().inflate(R.layout.activity_main_button, mGridLayout, false); button.setText(i + ""); mGridLayout.addView(button); } }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); mRootView = (ViewGroup) layoutInflater.inflate(R.layout.dialog_colors, null); mAlphaSeekBar = (SeekBar) mRootView.findViewById(android.R.id.progress); mAlphaSeekBar.setOnSeekBarChangeListener(alphaSeekListener); mAlphaSeekBar.setMax(255); mAlphaSeekBar.setProgress(getValueAlpha(false)); mColorGrid = (GridLayout) mRootView.findViewById(R.id.color_grid); mColorGrid.setColumnCount(mPreference.mNumColumns); repopulateItems(); return new AlertDialog.Builder(getActivity()) .setView(mRootView) .setNegativeButton(android.R.string.cancel, clickListener) .setPositiveButton(android.R.string.ok, clickListener) .create(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_theme); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mGrid = (GridLayout) findViewById(R.id.grid); mCurrentSelect = (View) findViewById(R.id.current_select); generateColoredButtons(); int spCurrent = getSharedPreferences(Constants.SP_FILE, Context.MODE_WORLD_READABLE).getInt(Constants.SP_BACKGROUND, 0); mCurrentSelect.setBackgroundColor(getResources().getColor(Constants.COLORS[spCurrent])); }
private void generateColoredButtons() { for (int i=0; i<ROWS; i++) { for (int j=0; j<COLUMNS; j++) { int count = COLUMNS * i + j; if (count > Constants.COLORS.length - 1) { return; } Button b = new Button(this); b.setBackgroundResource(R.drawable.round_button); b.setBackgroundColor(getResources().getColor(Constants.COLORS[count])); b.setTag(count); b.setOnClickListener(this); GridLayout.LayoutParams params = new GridLayout.LayoutParams(); params.height = GridLayout.LayoutParams.WRAP_CONTENT; params.width = GridLayout.LayoutParams.WRAP_CONTENT; params.rowSpec = GridLayout.spec(i); params.columnSpec = GridLayout.spec(j); b.setLayoutParams(params); mGrid.addView(b); } } }
@Override public void removeAttribute(View view, AttrLayoutContext attrCtx) { ViewGroup.LayoutParams params = view.getLayoutParams(); if (params instanceof GridLayout.LayoutParams) { // No hacemos nada, no puede ser cambiado "post-creación" } else if (params instanceof TableRow.LayoutParams) { ((TableRow.LayoutParams)params).column = -1; PendingViewPostCreateProcess.onChangedLayoutParams(view); } }
void initUI(View fragmentLayout) { gridLayout = (GridLayout) fragmentLayout.findViewById(R.id.metric_chooser_gridlayout); metricChooserTextView = (TextView) fragmentLayout.findViewById(R.id.metrics_chooser_textview); clearAllButton = (Button) fragmentLayout.findViewById(R.id.clear_all_button); clearAllButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { clearItems(); } } ); messageAtOrUnderLimitColor = ContextCompat.getColor(getActivity(), R.color.white); messageOverLimitColor = ContextCompat.getColor(getActivity(), R.color.red); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_folder_drawer_open); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); receiver = new ApplicationBroadcastReceiver(); registerReceiver(receiver, filter); mFolderName = (TextView) findViewById(R.id.folder_drawer_name); mToolbar = (RelativeLayout) findViewById(R.id.folder_drawer_header); mGridLayout = (GridLayout) findViewById(R.id.folder_grid_view); mBackImgBtn = (ImageButton) findViewById(R.id.folder_drawer_close_icon); Intent thisIntent = getIntent(); app = (LauncherApplication) thisIntent.getSerializableExtra("group"); String name = app.getName(); int toolbarColor = thisIntent.getIntExtra("toolbarColor", Color.GRAY); mFolderName.setText(name); mToolbar.setBackgroundColor(toolbarColor); mBackImgBtn.setOnClickListener(new OnSettingBackButtonClickListener(this)); populateFolderContent(); }
private GridLayout addTableHeader( String... headers ) { GridLayout gridLayout = new GridLayout( getContext() ); gridLayout.setBackgroundResource( R.color.grey_faint ); int rowNum = 0; int columnNum = 0; for ( String header : headers ) { RobotoTextView headerText = new RobotoTextView( getContext() ); headerText.setTextAppearance( getContext(), R.style.CardKey ); headerText.setText( header ); Spec rowspecs = GridLayout.spec( rowNum, 1 ); Spec colspecs = GridLayout.spec( columnNum, 1 ); GridLayout.LayoutParams params = new GridLayout.LayoutParams( rowspecs, colspecs ); params.setGravity( Gravity.CENTER_HORIZONTAL ); params.setMargins( getContext().getResources().getDimensionPixelSize( R.dimen.column_padding ), 0, getContext().getResources().getDimensionPixelSize( R.dimen.column_padding ), 0 ); gridLayout.addView( headerText, params ); columnNum++; } return gridLayout; }
private void addTableRow( GridLayout gridLayout, String... columns ) { int rowNum = gridLayout.getRowCount(); int columnNum = 0; for ( String column : columns ) { RobotoTextView columnText = new RobotoTextView( getContext() ); columnText.setTextAppearance( getContext(), R.style.CardValue ); columnText.setText( column ); Spec rowspecs = GridLayout.spec( rowNum, 1 ); Spec colspecs = GridLayout.spec( columnNum, 1 ); GridLayout.LayoutParams params = new GridLayout.LayoutParams( rowspecs, colspecs ); params.setGravity( Gravity.CENTER_HORIZONTAL ); gridLayout.addView( columnText, params ); columnNum++; } }