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:cn.caimatou.canting.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from ww w . j a v a 2 s . c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); int textSize = (mTextSize <= 0 ? TAB_VIEW_TEXT_SIZE_SP : mTextSize); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // TypedValue outValue = new TypedValue(); // getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, // outValue, true); // textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.auth0.android.lock.views.FormLayout.java
private void addSeparator() { orSeparatorMessage = new LineSpacingTextView(getContext()); orSeparatorMessage.setText(R.string.com_auth0_lock_forms_separator); 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); orSeparatorMessage.setPadding(0, verticalPadding, 0, verticalPadding); formsHolder.addView(orSeparatorMessage, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); }
From source file:com.andreapivetta.changemywall.tabs.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.// w ww. j av a 2s . c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.app.learn.Util.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from ww w . j av a 2 s .c om */ protected TextView createDefaultTabView(Context context) { TextView textView; textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(Color.WHITE); // \(^o^)/ ???? TextColor if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:fr.univsavoie.ltp.client.map.Popup.java
/** * Afficher sur la map un popup qui propose a l'utilisateur * de mettre a jours son status/*w w w. j av a 2s . co m*/ */ public final void popupPublishStatus() { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; int popupWidth = (int) (width * 0.75); //int popupHeight = height / 2; // Inflate the popup_layout.xml ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupStatus); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_set_status, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupPublishStatus.setBackgroundDrawable(new BitmapDrawable()); popupPublishStatus.setOutsideTouchable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. final int OFFSET_X = 0; final int OFFSET_Y = 0; // Displaying the popup at the specified location, + offsets. this.activity.findViewById(R.id.layoutMain).post(new Runnable() { public void run() { popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); } }); /* * Evenements composants du PopupWindow */ // Ecouteur d'vnement sur le bouton pour se dconnecter Button publish = (Button) layout.findViewById(R.id.btStatusPublish); publish.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText userStatus = (EditText) layout.findViewById(R.id.fieldUserStatus); if (userStatus.getText().toString().length() == 0) { Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); } else if (userStatus.getText().toString().length() < 3) { Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); } else { String json = "{\"ltp\":{\"application\":\"Client LTP\",\"status\":{\"lon\" : \"" + String.valueOf(activity.getLongitude()) + "\",\"lat\" : \"" + String.valueOf(activity.getLatitude()) + "\",\"content\" : \"" + userStatus.getText().toString() + "\"}}}"; activity.getSession().postJSON("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", json); Toast.makeText(activity, "Status mise a jours !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); // Actualise les marqueurs activity.displayFriends(); } } }); }
From source file:com.arce.angel.request.SlidingTab.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from ww w. j a va 2s. co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.alimuzaffar.ramadanalarm.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w .jav a 2 s. c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); if (mTextColor > 0) { textView.setTextColor(getContext().getResources().getColor(mTextColor)); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:br.comoferta.ui.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w. ja v a 2s. co m */ protected TextView createDefaultTabView(Context context) { ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_selected }, new int[] { -android.R.attr.state_selected }, }, new int[] { Color.WHITE, Color.LTGRAY }); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTextColor(colorStateList); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.ab.view.sliding.AbSlidingPlayView.java
/** * .//from ww w .jav a 2 s . co m */ public void creatIndex() { //? navLinearLayout.removeAllViews(); mNavLayoutParent.setHorizontalGravity(navHorizontalGravity); navLinearLayout.setGravity(Gravity.CENTER); navLinearLayout.setVisibility(View.VISIBLE); count = mListViews.size(); navLayoutParams.setMargins(5, 5, 5, 5); for (int j = 0; j < count; j++) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(navLayoutParams); if (j == 0) { imageView.setImageBitmap(displayImage); } else { imageView.setImageBitmap(hideImage); } navLinearLayout.addView(imageView, j); } }
From source file:com.appnexus.opensdk.MRAIDImplementation.java
void close() { if (expanded) { AdView.LayoutParams lp = new AdView.LayoutParams(owner.getLayoutParams()); lp.height = default_height; lp.width = default_width; lp.gravity = Gravity.CENTER; owner.setLayoutParams(lp);/*from w w w . j a va2 s .c o m*/ owner.close(); this.owner.loadUrl("javascript:window.mraid.util.stateChangeEvent('default');"); this.owner.owner.adListener.onAdCollapsed(this.owner.owner); // Allow orientation changes Activity a = ((Activity) this.owner.getContext()); if (a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); expanded = false; } else { // state must be default owner.hide(); hidden = true; } }