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:am.project.x.business.widgets.gradienttabstrip.GradientTabStripActivity.java
private ArrayList<View> getPagers() { ArrayList<View> views = new ArrayList<>(); for (int i = 0; i < 4; i++) { TextView text = new TextView(this); text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180); text.setText(String.format(Locale.getDefault(), "%d", i + 1)); text.setGravity(Gravity.CENTER); text.setTextColor(0xff000000);//from ww w. j ava 2 s. c om views.add(text); } return views; }
From source file:com.bangqu.eshow.util.ESDialogUtil.java
/** * ?. * @param view */ public static ESSampleDialogFragment showDialog(View view) { return showDialog(view, Gravity.CENTER); }
From source file:am.project.x.business.drawables.combinationdrawable.CombinationDrawableActivity.java
@SuppressLint("RtlHardcoded") @Override/* w w w.j a v a 2 s .c om*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { default: case 0: drawable.setGravity(Gravity.CENTER); break; case 1: drawable.setGravity(Gravity.LEFT); break; case 2: drawable.setGravity(Gravity.CENTER_HORIZONTAL); break; case 3: drawable.setGravity(Gravity.RIGHT); break; case 4: drawable.setGravity(Gravity.CENTER_VERTICAL); break; case 5: drawable.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT); break; case 6: drawable.setGravity(Gravity.BOTTOM); break; case 7: drawable.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); break; case 8: drawable.setGravity(Gravity.BOTTOM | Gravity.RIGHT); break; } }
From source file:com.android.calculator2.Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_VIEW_CONTAINER_ID); View cv = inflateView(savedInstanceState); cv.setId(android.R.id.content);/* ww w .j a va 2s.c om*/ lframe.addView(cv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:de.fahrgemeinschaft.util.ReoccuringWeekDaysView.java
private TextView makeRecurringDayButton(Context ctx) { TextView day = new UnScrollingTextView(ctx); if (clickable) day.setOnClickListener(toggleSelectedState); LayoutParams lp = new LayoutParams(0, LayoutParams.MATCH_PARENT); lp.weight = 1;/* www .ja v a 2 s. c om*/ day.setLayoutParams(lp); day.setTextAppearance(getContext(), R.style.dark_Bold); day.setBackgroundResource(R.drawable.btn_night); day.setGravity(Gravity.CENTER); day.setFocusable(true); return day; }
From source file:bottombar.BottomBarBadge.java
void attachToTab(BottomBarTab tab, int backgroundColor) { ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); setLayoutParams(params);//from w ww . j a va 2 s . co m setGravity(Gravity.CENTER); MiscUtils.setTextAppearance(this, R.style.BB_BottomBarBadge_Text); setColoredCircleBackground(backgroundColor); wrapTabAndBadgeInSameContainer(tab); }
From source file:net.bible.android.view.util.widget.BookmarkStyleAdapterHelper.java
public void styleView(TextView view, BookmarkStyle bookmarkStyle, Context context, boolean overrideText, boolean centreText) { // prepare text to be shown String baseText;/*from w w w .j av a 2 s. c o m*/ if (overrideText) { baseText = sampleText; } else { baseText = view.getText().toString(); // avoid multiple *'s if (baseText.startsWith("*")) { StringUtils.strip(baseText, "*"); } } int backgroundColor = Color.WHITE; switch (bookmarkStyle) { case YELLOW_STAR: backgroundColor = UiUtils.getThemeBackgroundColour(context); view.setTextColor(UiUtils.getThemeTextColour(context)); CharSequence imgText = addImageAtStart("* " + baseText, R.drawable.goldstar16x16, context); view.setText(imgText, TextView.BufferType.SPANNABLE); break; case RED_HIGHLIGHT: backgroundColor = BookmarkStyle.RED_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; case YELLOW_HIGHLIGHT: backgroundColor = BookmarkStyle.YELLOW_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; case GREEN_HIGHLIGHT: backgroundColor = BookmarkStyle.GREEN_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; case BLUE_HIGHLIGHT: backgroundColor = BookmarkStyle.BLUE_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; } view.setBackgroundColor(backgroundColor); view.setHeight(CommonUtils.convertDipsToPx(30)); if (centreText) { view.setGravity(Gravity.CENTER); } }
From source file:com.knurld.dropboxdemo.KnurldActivity.java
public PopupWindow showLoadingPopup(View view) { View spinnerView = LayoutInflater.from((Activity) context).inflate(R.layout.loading_popup, null); ProgressBar progressBar = (ProgressBar) spinnerView.findViewById(R.id.speakProgress); progressBar.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY); PopupWindow popupWindow = new PopupWindow(spinnerView, 500, 500); popupWindow.setFocusable(true);/*from w w w . j a va 2s. c o m*/ popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0); return popupWindow; }
From source file:cc.metapro.openct.customviews.DuringDialog.java
private void setViews(GridLayout gridLayout) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 6; j++) { final int week = i * 6 + j + 1; final TextView textView = new TextView(getActivity()); textView.setText(week + gridLayout.getContext().getString(R.string.week)); textView.setGravity(Gravity.CENTER); if (DURING[week]) { textView.setBackground(/* w ww .ja v a 2s.co m*/ ContextCompat.getDrawable(getActivity(), R.drawable.text_view_card_style_blue)); textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); } else { textView.setBackground( ContextCompat.getDrawable(getActivity(), R.drawable.text_view_card_style_grey)); textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.material_grey)); } textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DURING[week] = !DURING[week]; } }); GridLayout.Spec row = GridLayout.spec(i, 1, 1); GridLayout.Spec col = GridLayout.spec(j, 1, 1); GridLayout.LayoutParams params = new GridLayout.LayoutParams(row, col); gridLayout.addView(textView, params); selections[i][j] = textView; } } }
From source file:com.antonioleiva.materialeverywhere.HomeActivity1.java
public void Notification_Vibration() { long[] vibrationPattern = { 0, 500, 0, 30 }; NotificationManager notifier = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifier.cancel(RECIPE_NOTIFICATION_ID); //step6//from w ww. j av a 2 s. c o m Notification fourthPage = new NotificationCompat.Builder(this).setContentTitle("Step 6") .setContentText(" ? .") .extend(new NotificationCompat.WearableExtender().setContentIcon(R.drawable.ic_launcher) .setContentIconGravity(Gravity.CENTER)) .build(); NotificationCompat.WearableExtender wearableOptions = new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.ic_launcher).setContentIconGravity(Gravity.CENTER).addPage(fourthPage); Notification notification1 = new NotificationCompat.Builder(this).setContentTitle("? ") .setContentText("? ").setSmallIcon(R.drawable.ic_launcher) .setVibrate(vibrationPattern).extend(wearableOptions).build(); NotificationManagerCompat.from(this).notify(FINISH_STEP, notification1); }