List of usage examples for android.widget ImageView getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:android.support.asy.image.ImageWorker.java
private void calculateImageViewHeight(String url, ImageView imageView) { String fileName = ((HotPotApplication) ((Activity) mContext).getApplication()) .getCacheImageAbsolutePath(url); final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;/*from w w w . j a v a 2 s . com*/ BitmapFactory.decodeFile(fileName, options); int width = options.outWidth; int height = options.outHeight; if (width != 0) { final int imageViewHeight = mScreenWidth * height / width; if (imageViewHeight != 0) { LayoutParams lp = imageView.getLayoutParams(); if (lp == null) { lp = new LayoutParams(mScreenWidth, imageViewHeight); imageView.setLayoutParams(lp); } else { lp.width = mScreenWidth; lp.height = imageViewHeight; } imageView.invalidate(); } } }
From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java
private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) { FrameLayout tabfl = new FrameLayout(getContext()); ImageView tabi = new ImageView(getContext()); tabi.setContentDescription(title); tabi.setImageResource(resId);//from w w w . j a va 2 s .c o m tabi.setVisibility(View.INVISIBLE); TextView tabt = new TextView(getContext()); tabt.setText(title); tabt.setTypeface(App.skrift_gibson); tabt.setGravity(Gravity.CENTER); tabt.setSingleLine(); tabfl.addView(tabi); tabfl.addView(tabt); LayoutParams lp = (LayoutParams) tabi.getLayoutParams(); lp.gravity = Gravity.CENTER; lp = (LayoutParams) tabt.getLayoutParams(); lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT; lp.gravity = Gravity.CENTER; addTab(position, tabfl); }
From source file:com.asksven.betterbatterystats.adapters.StatsAdapter.java
public View getView(int position, View convertView, ViewGroup viewGroup) { StatElement entry = m_listData.get(position); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.m_context); boolean bShowBars = sharedPrefs.getBoolean("show_gauge", false); if (LogSettings.DEBUG) { Log.i(TAG, "Values: " + entry.getVals()); }//from w w w. j av a2s .c om if (convertView == null) { LayoutInflater inflater = (LayoutInflater) m_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // depending on settings show new pie gauge or old bar gauge if (!bShowBars) { convertView = inflater.inflate(R.layout.stat_row, null); } else { convertView = inflater.inflate(R.layout.stat_row_gauge, null); } } final float scale = this.m_context.getResources().getDisplayMetrics().density; TextView tvName = (TextView) convertView.findViewById(R.id.TextViewName); ///////////////////////////////////////// // we do some stuff here to handle settings about font size and thumbnail size String fontSize = sharedPrefs.getString("medium_font_size", "16"); int mediumFontSize = Integer.parseInt(fontSize); //we need to change "since" fontsize tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, mediumFontSize); // We need to handle an exception here: Sensors do not have a name so we use the fqn instead if (entry instanceof SensorUsage) { tvName.setText(entry.getFqn(UidNameResolver.getInstance(m_context))); } else { tvName.setText(entry.getName()); } boolean bShowKb = sharedPrefs.getBoolean("enable_kb", true); ImageView iconKb = (ImageView) convertView.findViewById(R.id.imageKB); iconKb.setVisibility(View.INVISIBLE); TextView tvFqn = (TextView) convertView.findViewById(R.id.TextViewFqn); tvFqn.setText(entry.getFqn(UidNameResolver.getInstance(m_context))); TextView tvData = (TextView) convertView.findViewById(R.id.TextViewData); // for alarms the values is wakeups per hour so we need to take the time as reference for the text if (entry instanceof Alarm) { tvData.setText(entry.getData((long) m_timeSince)); } else { tvData.setText(entry.getData((long) m_maxValue)); } //LinearLayout myLayout = (LinearLayout) convertView.findViewById(R.id.LinearLayoutBar); LinearLayout myFqnLayout = (LinearLayout) convertView.findViewById(R.id.LinearLayoutFqn); LinearLayout myRow = (LinearLayout) convertView.findViewById(R.id.LinearLayoutEntry); // long press for "copy to clipboard" convertView.setOnLongClickListener(new OnItemLongClickListener(position)); if (!bShowBars) { GraphablePie gauge = (GraphablePie) convertView.findViewById(R.id.Gauge); ///////////////////////////////////////// // we do some stuff here to handle settings about font size and thumbnail size String iconDim = sharedPrefs.getString("thumbnail_size", "56"); int iconSize = Integer.parseInt(iconDim); int pixels = (int) (iconSize * scale + 0.5f); //we need to change "since" fontsize gauge.getLayoutParams().height = pixels; gauge.getLayoutParams().width = pixels; gauge.requestLayout(); //////////////////////////////////////////////////////////////////////////////////// if (entry instanceof NetworkUsage) { gauge.setValue(entry.getValues()[0], ((NetworkUsage) entry).getTotal()); } else { double max = m_maxValue; // avoid rounding errors leading to values > 100 % if (entry.getValues()[0] > max) { max = entry.getValues()[0]; Log.i(TAG, "Upping gauge max to " + max); } gauge.setValue(entry.getValues()[0], max); } } else { GraphableBars buttonBar = (GraphableBars) convertView.findViewById(R.id.ButtonBar); int iHeight = 10; try { iHeight = Integer.valueOf(sharedPrefs.getString("graph_bar_height", "10")); } catch (Exception e) { iHeight = 10; } if (iHeight == 0) { iHeight = 10; } buttonBar.setMinimumHeight(iHeight); buttonBar.setName(entry.getName()); buttonBar.setValues(entry.getValues(), m_maxValue); } ImageView iconView = (ImageView) convertView.findViewById(R.id.icon); LinearLayout iconLayout = (LinearLayout) convertView.findViewById(R.id.LayoutIcon); ///////////////////////////////////////// // we do some stuff here to handle settings about font size and thumbnail size String iconDim = sharedPrefs.getString("thumbnail_size", "56"); int iconSize = Integer.parseInt(iconDim); int pixels = (int) (iconSize * scale + 0.5f); //we need to change "since" fontsize iconView.getLayoutParams().width = pixels; iconView.getLayoutParams().height = pixels; iconView.requestLayout(); //n 20;setLay.setTextSize(TypedValue.COMPLEX_UNIT_DIP, iconSize); //////////////////////////////////////////////////////////////////////////////////// // add on click listener for the icon only if KB is enabled // if (bShowKb) // { // // set a click listener for the list // iconKb.setOnClickListener(new OnIconClickListener(position)); // } // show / hide fqn text if ((entry instanceof Process) || (entry instanceof State) || (entry instanceof Misc) || (entry instanceof NativeKernelWakelock) || (entry instanceof Alarm) || (entry instanceof SensorUsage)) { myFqnLayout.setVisibility(View.GONE); } else { myFqnLayout.setVisibility(View.VISIBLE); } // show / hide package icons (we show / hide the whole layout as it contains a margin that must be hidded as well if ((entry instanceof NativeKernelWakelock) || (entry instanceof State) || (entry instanceof Misc)) { iconView.setVisibility(View.GONE); } else { iconView.setVisibility(View.VISIBLE); iconView.setImageDrawable(entry.getIcon(UidNameResolver.getInstance(m_context))); // set a click listener for the list iconView.setOnClickListener(new OnPackageClickListener(position)); } // add on click listener for the list entry if details are availble if ((entry instanceof Alarm) || (entry instanceof NativeKernelWakelock) || (entry instanceof SensorUsage)) { convertView.setOnClickListener(new OnItemClickListener(position)); } // // show / hide set dividers // ListView myList = (ListView) convertView.getListView(); //findViewById(R.id.id.list); // myList.setDivider(new ColorDrawable(0x99F10529)); // myList.setDividerHeight(1); return convertView; }
From source file:com.pongme.utils.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not * used. Kept private at the moment as its interest is not clear. *//* w w w. j av a 2s .c o m*/ private BitmapDownloaderTask forceDownload(String url, ImageView imageView, BitmapDrawable tempImage) { // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys. BitmapDownloaderTask task = null; if (url == null) { imageView.setImageDrawable(null); // imageView.setImageResource(R.drawable.home_img_download); return null; } int w = 0, h = 0; LayoutParams params = imageView.getLayoutParams(); if (params != null) { w = params.width; h = params.height; } // Change Task attributes if exist intead of Cancel if (refactorPotentialDownload(url, imageView, w, h)) { switch (mode) { case NO_ASYNC_TASK: Bitmap bitmap = downloadBitmap(url, w, h); addBitmapToCache(url, bitmap); imageView.setImageBitmap(bitmap); break; case NO_DOWNLOADED_DRAWABLE: imageView.setMinimumHeight(96); imageView.setMinimumWidth(128); task = new BitmapDownloaderTask(imageView, w, h); task.execute(url); break; case CORRECT: task = new BitmapDownloaderTask(imageView, w, h); DownloadedDrawable downloadedDrawable = null; if (tempImage != null) { downloadedDrawable = new DownloadedDrawable(task, tempImage); } else { downloadedDrawable = new DownloadedDrawable(task); } int minWith = 0; int minheight = 0; if (params != null) { minWith = params.width; minheight = params.height; } imageView.setImageDrawable(downloadedDrawable); imageView.setMinimumWidth(minWith); imageView.setMinimumHeight(minheight); task.execute(url); break; } } return task; }
From source file:org.i_chera.wolfensteineditor.fragments.LevelFragment.java
@Override public void moveVisTile(int i1, int j1, int i2, int j2) { int ms = LevelContainer.MAPSIZE - 1; if (!Global.inBounds(i2, 0, ms) || !Global.inBounds(j2, 0, ms)) { // Log.d(TAG, "Refused move " + i1 + " " + j1 + " " + i2 + " " + j2); return;//from w w w .ja va 2s .c o m } ImageView iv = null; if (Global.inBounds(i1, 0, ms) && Global.inBounds(j1, 0, ms)) iv = mTileViews[i1][j1]; // let's be careful, okay? if (iv == null) { // either just create or update iv = mTileViews[i2][j2]; if (iv == null) createVisTile(i2, j2); else updateGraphics(iv, j2, i2); } else { // delete or move ImageView iv2 = mTileViews[i2][j2]; if (iv2 == null) { RelativeLayout.LayoutParams rllp = (RelativeLayout.LayoutParams) iv.getLayoutParams(); rllp.leftMargin = j2 * mTileSize; rllp.topMargin = i2 * mTileSize; mTileViews[i1][j1] = null; mTileViews[i2][j2] = iv; mTileViews[i2][j2].setId(i2 * LevelContainer.MAPSIZE + j2); // mGridLayout.invalidate(new Rect(rllp.leftMargin, rllp.topMargin, // rllp.leftMargin + mTileSize, rllp.topMargin + mTileSize)); updateGraphics(iv, j2, i2); } else { // delete the old one mGridLayout.removeView(iv); mTileViews[i1][j1] = null; updateGraphics(iv2, j2, i2); } } }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
private View getEmptyHomeView(LayoutInflater inflater) { final View emptyHomeView = inflater.inflate(R.layout.empty_home_view, null); // Set image margins. final ImageView image = (ImageView) emptyHomeView.findViewById(R.id.empty_home_image); final LayoutParams params = (LayoutParams) image.getLayoutParams(); final int screenHeight = getResources().getDisplayMetrics().heightPixels; final int marginTop = screenHeight / 2 - getResources().getDimensionPixelSize(R.dimen.empty_home_view_image_offset); params.setMargins(0, marginTop, 0, 0); params.gravity = Gravity.CENTER_HORIZONTAL; image.setLayoutParams(params);/*from ww w . j a v a 2 s.c om*/ // Set up add contact button. final Button addContactButton = (Button) emptyHomeView.findViewById(R.id.add_contact_button); addContactButton.setOnClickListener(mAddContactListener); return emptyHomeView; }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
private View getEmptyAccountView(LayoutInflater inflater) { final View emptyAccountView = inflater.inflate(R.layout.empty_account_view, null); // Set image margins. final ImageView image = (ImageView) emptyAccountView.findViewById(R.id.empty_account_image); final LayoutParams params = (LayoutParams) image.getLayoutParams(); final int height = getResources().getDisplayMetrics().heightPixels; final int divisor = getResources().getInteger(R.integer.empty_account_view_image_margin_divisor); final int offset = getResources().getDimensionPixelSize(R.dimen.empty_account_view_image_offset); params.setMargins(0, height / divisor + offset, 0, 0); params.gravity = Gravity.CENTER_HORIZONTAL; image.setLayoutParams(params);/*ww w . j a v a 2s . c o m*/ // Set up add contact button. final Button addContactButton = (Button) emptyAccountView.findViewById(R.id.add_contact_button); addContactButton.setOnClickListener(mAddContactListener); return emptyAccountView; }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void updateViewSize(ImageView iconView) { int intrinsicWidth = iconView.getDrawable().getIntrinsicWidth(); LayoutParams lp = iconView.getLayoutParams(); if (intrinsicWidth > 0) { lp.height = lp.width * iconView.getDrawable().getIntrinsicHeight() / intrinsicWidth; } else {/*from w ww .j ava2 s . co m*/ // If no intrinsic width, then just mke this a square. lp.height = lp.width; } }
From source file:org.sirimangalo.meditationplus.ActivityMain.java
private void populateLog(JSONArray jsonLogged) { Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); int hour = utc.get(Calendar.HOUR_OF_DAY); int max_hour = 0; int max_height = 100; LinearLayout hll = (LinearLayout) findViewById(R.id.time_log); if (hll == null) return;/*from www. j a v a 2 s . c o m*/ hll.removeAllViews(); try { max_hour = jsonLogged.getInt(0); for (int i = 1; i < jsonLogged.length(); i++) { max_hour = Math.max(max_hour, jsonLogged.getInt(i)); } for (int i = 0; i < jsonLogged.length(); i++) { int height = (int) Math.ceil(max_height * jsonLogged.getInt(i) / max_hour); LinearLayout ll = (LinearLayout) context.getLayoutInflater().inflate(R.layout.list_item_log, null); ImageView iv = (ImageView) ll.findViewById(R.id.min_cell); iv.getLayoutParams().height = height; iv.getLayoutParams().width = hll.getWidth() / 24; TextView tv = (TextView) ll.findViewById(R.id.hour_no); tv.setText(i + ""); if (hour == i) tv.setBackgroundColor(0xFFFFFF33); ImageView sv = (ImageView) ll.findViewById(R.id.space_cell); sv.getLayoutParams().height = 100 - height; hll.addView(ll); } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.b44t.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);//from w w w .j a v a 2 s . c o m setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: appendCharacter("0"); break; case 1: appendCharacter("1"); break; case 2: appendCharacter("2"); break; case 3: appendCharacter("3"); break; case 4: appendCharacter("4"); break; case 5: appendCharacter("5"); break; case 6: appendCharacter("6"); break; case 7: appendCharacter("7"); break; case 8: appendCharacter("8"); break; case 9: appendCharacter("9"); break; case 10: String text = passwordEditText.getText().toString(); if (text.length() > 0) { passwordEditText.setText(text.substring(0, text.length() - 1)); } break; } if (passwordEditText.getText().toString().length() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }