List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:com.auth0.android.lock.views.PasswordlessFormLayout.java
private void addSeparator() { orSeparatorMessage = new LineSpacingTextView(getContext()); int passwordlessMode = lockWidget.getConfiguration().getPasswordlessMode(); int stringRes = R.string.com_auth0_lock_passwordless_email_forms_separator; if (passwordlessMode == PasswordlessMode.SMS_LINK || passwordlessMode == PasswordlessMode.SMS_CODE) { stringRes = R.string.com_auth0_lock_passwordless_sms_forms_separator; }/*from w ww . j a v a 2s. c om*/ orSeparatorMessage.setText(stringRes); orSeparatorMessage .setLineSpacing(getResources().getDimension(R.dimen.com_auth0_lock_separator_text_spacing), 1); orSeparatorMessage.setTextColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_text)); orSeparatorMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_auth0_lock_title_text)); orSeparatorMessage.setGravity(Gravity.CENTER); int verticalPadding = getResources() .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field); LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(0, verticalPadding, 0, verticalPadding); addView(orSeparatorMessage, params); }
From source file:com.insthub.O2OMobile.Activity.C12_EditSignatureActivity.java
@Override public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException { if (url.endsWith(ApiInterface.USER_CHANGE_PROFILE)) { ToastView toast = new ToastView(C12_EditSignatureActivity.this, getString(R.string.signature_success)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();// w ww .j a v a2s . c o m finish(); } }
From source file:com.androcast.illusion.illusionmod.fragments.PathReaderFragment.java
private void showDialog(final String file, String value) { LinearLayout layout = new LinearLayout(getActivity()); layout.setPadding(30, 30, 30, 30);// w ww .j a v a2s.c o m final EditText editText = new EditText(getActivity()); editText.setGravity(Gravity.CENTER); editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (!Utils.DARKTHEME) editText.setTextColor(getResources().getColor(R.color.black)); editText.setText(value); layout.addView(editText); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(layout) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Control.runCommand(editText.getText().toString(), file, Control.CommandType.GENERIC, getActivity()); refreshLayout.setRefreshing(true); getHandler().postDelayed(refresh, 500); } }).show(); }
From source file:hongik.android.project.best.StoreActivity.java
public void drawPage() throws Exception { String query = "func=storereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();//from www .j a v a2 s . c o m conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) return; final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0); JSONArray menu = null; if (!jsonResult.isNull("menu")) menu = jsonResult.getJSONArray("menu"); JSONArray review = null; if (!jsonResult.isNull("review")) review = jsonResult.getJSONArray("review"); //Draw Store Information Lat = Double.parseDouble(store.getString("LAT")); Lng = Double.parseDouble(store.getString("LNG")); sname = store.getString("SNAME"); ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname); ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR")); ImageLoader imgLoader = new ImageLoader(store.getString("IMG")); imgLoader.start(); try { imgLoader.join(); Bitmap storeImg = imgLoader.getBitmap(); ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg); } catch (InterruptedException e) { Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show(); Log.e("StoreInfo", "Can not bring " + license + "store's image"); } //Draw Menu Table if (menu != null) { TableRow motive = (TableRow) menuTable.getChildAt(1); for (int i = 0; i < menu.length(); i++) { JSONObject json = menu.getJSONObject(i); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[3]; final String[] elements = new String[2]; elements[0] = json.getString("ITEM#"); elements[1] = json.getString("PRICE"); imgLoader = new ImageLoader(json.getString("IMG")); imgLoader.start(); imgLoader.join(); ImageView img = new ImageView(this); Bitmap bitmap = imgLoader.getBitmap(); img.setImageBitmap(bitmap); img.setLayoutParams(motive.getChildAt(0).getLayoutParams()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); tbRow.addView(img); for (int j = 0; j < 2; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } menuTable.addView(tbRow); } } menuTable.removeViewAt(1); //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); int rowCnt = 5; if (review.length() < 5) rowCnt = review.length(); for (int i = 0; i < rowCnt; i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.store_map); mapFragment.getMapAsync(this); }
From source file:com.acceleratedio.pac_n_zoom.FindTagsActivity.java
private void dsply_tags() { TableLayout tbl_tag_lo = (TableLayout) findViewById(R.id.tl_tag); int tag_mbr = 0; int tag_nmbr = fil_tags.length; String lst_str = ""; int row_mbr;//from ww w. j av a 2 s .c o m tbl_tag_lo.setAlpha(185); // - Find the search string srch_str = srch_str.trim(); boolean flg_srch_tags = !srch_str.equals(""); if (flg_srch_tags) { String[] srch_ary = srch_str.split("\\s* \\s*"); srch_str = srch_ary[srch_ary.length - 1].toLowerCase(); } // - Remove any current rows int row_nmbr = tbl_tag_lo.getChildCount(); if (row_nmbr > 0) tbl_tag_lo.removeAllViews(); for (row_mbr = 0; row_mbr < 4 && tag_mbr < tag_nmbr; row_mbr++) { TableRow tableRow = new TableRow(this); tableRow.setGravity(Gravity.CENTER); tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT, 1.0f)); for (int clm_mbr = 0; clm_mbr < 3; clm_mbr++) { Button btnTag = new Button(this); while (tag_mbr < tag_nmbr && (fil_tags[tag_mbr].equals("") || fil_tags[tag_mbr].equalsIgnoreCase(lst_str) || flg_srch_tags && !fil_tags[tag_mbr].toLowerCase().startsWith(srch_str))) { lst_str = fil_tags[tag_mbr]; tag_mbr++; } if (tag_mbr >= tag_nmbr) break; lst_str = fil_tags[tag_mbr]; btnTag.setText(fil_tags[tag_mbr++]); btnTag.setOnClickListener(this); btnTag.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); tableRow.addView(btnTag); } tbl_tag_lo.addView(tableRow); } }
From source file:de.madvertise.android.sdk.MadView.java
/** * Constructor/*from www.j a v a2 s. c o m*/ * * @param context * @param attrs */ public MadView(Context context, AttributeSet attrs) { super(context, attrs); MadUtil.logMessage(null, Log.DEBUG, "** Constructor for mad view called **"); setVisibility(INVISIBLE); if (context.checkCallingOrSelfPermission( android.Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED) { MadUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** "); MadUtil.logMessage(null, Log.DEBUG, " *** Missing internet permissions! *** "); MadUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** "); throw new IllegalArgumentException(); } initParameters(attrs); Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); MadUtil.logMessage(null, Log.DEBUG, "Display values: Width = " + display.getWidth() + " ; Height = " + display.getHeight()); setGravity(Gravity.CENTER); initialBackground = this.getBackground(); Rect r = new Rect(0, 0, display.getWidth(), display.getHeight()); textBannerBackground = generateBackgroundDrawable(r, backgroundColor, 0xffffff); setClickable(true); setFocusable(true); setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); }
From source file:edgargtzg.popularmovies.DiscoverMoviesFragment.java
/** * Updates the content of the view based on the selected sort by * option by the User./*from ww w . j a va2 s . com*/ * * @param sortById id of the action to sort the movies * (for example: most popular, highest-rated) */ private void updateMovies(String sortById) { if (isNetworkAvailable()) { FetchMoviesTask fetchMoviesTask = new FetchMoviesTask(); fetchMoviesTask.execute(sortById); } else { Toast toast = Toast.makeText(getActivity(), R.string.error_msg_no_network, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } }
From source file:com.android.adam.navigation.BottomNavigationViewNew.java
public BottomNavigationViewNew(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Create the menu mMenu = new BottomNavigationMenu(context); mMenuView = new BottomNavigationMenuView(context); LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; mMenuView.setLayoutParams(params);/*from w w w. ja v a 2 s.c om*/ mPresenter.setBottomNavigationMenuView(mMenuView); mPresenter.setId(MENU_PRESENTER_ID); mMenuView.setPresenter(mPresenter); mMenu.addMenuPresenter(mPresenter); mPresenter.initForMenu(getContext(), mMenu); // Custom attributes TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, android.support.design.R.styleable.BottomNavigationView, defStyleAttr, android.support.design.R.style.Widget_Design_BottomNavigationView); if (a.hasValue(android.support.design.R.styleable.BottomNavigationView_itemIconTint)) { mMenuView.setIconTintList( a.getColorStateList(android.support.design.R.styleable.BottomNavigationView_itemIconTint)); } else { mMenuView.setIconTintList(createDefaultColorStateList(android.R.attr.textColorSecondary)); } if (a.hasValue(android.support.design.R.styleable.BottomNavigationView_itemTextColor)) { mMenuView.setItemTextColor( a.getColorStateList(android.support.design.R.styleable.BottomNavigationView_itemTextColor)); } else { mMenuView.setItemTextColor(createDefaultColorStateList(android.R.attr.textColorSecondary)); } if (a.hasValue(android.support.design.R.styleable.BottomNavigationView_elevation)) { ViewCompat.setElevation(this, a.getDimensionPixelSize(android.support.design.R.styleable.BottomNavigationView_elevation, 0)); } int itemBackground = a.getResourceId(android.support.design.R.styleable.BottomNavigationView_itemBackground, 0); mMenuView.setItemBackgroundRes(itemBackground); if (a.hasValue(android.support.design.R.styleable.BottomNavigationView_menu)) { inflateMenu(a.getResourceId(android.support.design.R.styleable.BottomNavigationView_menu, 0)); } a.recycle(); addView(mMenuView, params); if (Build.VERSION.SDK_INT < 21) { addCompatibilityTopDivider(context); } mMenu.setCallback(new MenuBuilder.Callback() { @Override public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { if (mReselectedListener != null && item.getItemId() == getSelectedItemId()) { mReselectedListener.onNavigationItemReselected(item); return true; // item is already selected } return mSelectedListener != null && !mSelectedListener.onNavigationItemSelected(item); } @Override public void onMenuModeChange(MenuBuilder menu) { } }); }
From source file:com.android.firewall.FirewallListPage.java
private TextView getTabView(int width, int height, String title) { TextView view = new TextView(this); view.setMinimumWidth(width);//from w w w . j ava 2 s . c o m view.setMinimumHeight(height); view.setGravity(Gravity.CENTER); view.setBackgroundResource(R.drawable.tab_indicator_holo); view.setText(title); return view; }
From source file:android.support.design.widget.BottomNavigationView.java
public BottomNavigationView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Create the menu mMenu = new BottomNavigationMenu(context); mMenuView = new BottomNavigationMenuView(context); LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; mMenuView.setLayoutParams(params);/* w w w .j a v a 2s. c om*/ mPresenter.setBottomNavigationMenuView(mMenuView); mPresenter.setId(MENU_PRESENTER_ID); mMenuView.setPresenter(mPresenter); mMenu.addMenuPresenter(mPresenter); mPresenter.initForMenu(getContext(), mMenu); // Custom attributes TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.BottomNavigationView, defStyleAttr, R.style.Widget_Design_BottomNavigationView); if (a.hasValue(R.styleable.BottomNavigationView_itemIconTint)) { mMenuView.setIconTintList(a.getColorStateList(R.styleable.BottomNavigationView_itemIconTint)); } else { mMenuView.setIconTintList(createDefaultColorStateList(android.R.attr.textColorSecondary)); } if (a.hasValue(R.styleable.BottomNavigationView_itemTextColor)) { mMenuView.setItemTextColor(a.getColorStateList(R.styleable.BottomNavigationView_itemTextColor)); } else { mMenuView.setItemTextColor(createDefaultColorStateList(android.R.attr.textColorSecondary)); } if (a.hasValue(R.styleable.BottomNavigationView_elevation)) { ViewCompat.setElevation(this, a.getDimensionPixelSize(R.styleable.BottomNavigationView_elevation, 0)); } int itemBackground = a.getResourceId(R.styleable.BottomNavigationView_itemBackground, 0); mMenuView.setItemBackgroundRes(itemBackground); if (a.hasValue(R.styleable.BottomNavigationView_menu)) { inflateMenu(a.getResourceId(R.styleable.BottomNavigationView_menu, 0)); } a.recycle(); addView(mMenuView, params); if (Build.VERSION.SDK_INT < 21) { addCompatibilityTopDivider(context); } mMenu.setCallback(new MenuBuilder.Callback() { @Override public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { if (mReselectedListener != null && item.getItemId() == getSelectedItemId()) { mReselectedListener.onNavigationItemReselected(item); return true; // item is already selected } return mSelectedListener != null && !mSelectedListener.onNavigationItemSelected(item); } @Override public void onMenuModeChange(MenuBuilder menu) { } }); }