List of usage examples for android.widget TextView setGravity
public void setGravity(int gravity)
From source file:com.TakeTaxi.jy.OnrouteScreen.java
public void pingpicked(JSONObject json) { try {//from w ww . j a va2s.c o m int driverpicked = json.getInt("picked"); int drivercancelled = json.getInt("dcancel"); int starttime = json.getInt("datetime"); // /////////////////////////////// DRIVER CANCEL //////// if (drivercancelled == 1) { // //// DRIVER CANCEL LATE ///// if (starttime + 300 <= Query.getServerTime()) { handlerboolean = false; handler.removeCallbacks(r); AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create(); dcancelbuilder .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?."); // //// DRIVER CANCEL LATE - NO REPORT LATE///// button_cancelJob_noquery(dcancelbuilder); // //// DRIVER CANCEL LATE - REPORT LATE ///// button_drivercancel_reportlate(dcancelbuilder); dcancelbuilder.show(); } else { // /////////////////////////////// DRIVER CANCEL NO ALERTS - // WITHIN TIME LIMIT/////////////// handlerboolean = false; handler.removeCallbacks(r); alertdialog_drivercancelintime(); } } if (driverpicked == 1) { // /////////////////////////////// CONFIRM PICK UP // /////////////////////////////////////////// handlerboolean = false; handler.removeCallbacks(r); AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this); final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup); final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite); final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown); final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite); LinearLayout layout = new LinearLayout(OnrouteScreen.this); layout.setOrientation(1); layout.setGravity(17); TextView tx1 = new TextView(OnrouteScreen.this); tx1.setText("Driver says you have been picked up"); tx1.setGravity(17); tx1.setTextSize(20); tx1.setTextColor(Color.WHITE); tx1.setPadding(10, 10, 10, 10); TextView tx2 = new TextView(OnrouteScreen.this); tx2.setText("Please rate your driver"); tx2.setGravity(17); tx2.setTextSize(16); LinearLayout imglayout = new LinearLayout(OnrouteScreen.this); imglayout.setOrientation(0); imglayout.setGravity(17); final ImageView ivup = new ImageView(OnrouteScreen.this); ivup.setImageDrawable(thumbsupwhite); ivup.setClickable(true); ivup.setPadding(0, 5, 30, 5); final ImageView ivdown = new ImageView(OnrouteScreen.this); ivdown.setImageDrawable(thumbsdownwhite); ivdown.setClickable(true); ivup.setPadding(30, 5, 0, 5); imglayout.addView(ivup); imglayout.addView(ivdown); layout.addView(tx1); layout.addView(tx2); layout.addView(imglayout); // /////////////////////////////// CONFIRM PICK UP - RATINGS // /////////////////////////////////////////// ivup.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsupboolean == false) { thumbsupboolean = true; thumbsdownboolean = false; ivup.setImageDrawable(thumbsup); ivdown.setImageDrawable(thumbsdownwhite); rating = 1; } else { thumbsupboolean = false; ivup.setImageDrawable(thumbsupwhite); rating = 0; } } }); ivdown.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsdownboolean == false) { thumbsdownboolean = true; thumbsupboolean = false; ivdown.setImageDrawable(thumbsdown); ivup.setImageDrawable(thumbsupwhite); AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create(); alert.setMessage("Please pick one"); alert.setButton("No show", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -1; } }); alert.setButton2("Driver late", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -2; } }); alert.setButton3("Poor service", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -3; } }); alert.show(); } else { thumbsupboolean = false; ivdown.setImageDrawable(thumbsdownwhite); rating = 0; } } }); button_completed_finish(alert); alert.setView(layout); alert.create(); alert.show(); } else { } } catch (JSONException e) { } }
From source file:com.hybunion.member.view.PagerSlidingTabStrip.java
private void addTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setWidth(screenWidth / tabCount);// tab.setText(title);// w w w. jav a 2 s . c om tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.liushengfan.test.customerviewgroup.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, SpannableString title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w ww . j a v a 2 s .c o m*/ tab.setMovementMethod(LinkMovementMethod.getInstance()); tab.setGravity(Gravity.CENTER); tab.setMaxLines(2); tab.setSingleLine(false); addTab(position, tab); }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert/* w w w. j ava 2s .co m*/ * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }
From source file:com.itheima.googlemarket.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); if (position == 0) { tab.setSelected(true); // ?1tab }// ww w . j a v a2s . c o m tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.example.view.astuetz.PagerSlidingTabStrip.java
@SuppressLint("NewApi") private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f)); tab.setText(title);/*from w w w . j av a2 s.c om*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.guerinet.materialtabs.TabLayout.java
/** * Creates a default view to be used for tabs. This is called if a custom tab view is not set * via {@link #setCustomTabView(int, int)}. * * @return The default view to use/*from www. java2 s. c o m*/ */ protected TextView createDefaultTabView() { TextView textView = new TextView(getContext()); prepareTextView(textView); textView.setGravity(Gravity.CENTER); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //Set the text color if there is one if (this.mDefaultTextColorId != null) { textView.setTextColor(getResources().getColor(mDefaultTextColorId)); } textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setBackgroundResource(getTabBackground()); //Padding int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.android.yijiang.kzx.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext(), null, android.R.attr.textAppearanceMedium); tab.setText(title);// w w w . j av a 2s. c o m tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.mingle.discolor.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title, int width) { TextView tab = new TextView(getContext()); tab.setText(title);// w w w. j a va 2 s . c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); android.view.ViewGroup.LayoutParams params = tab.getLayoutParams(); if (params == null) { params = new LayoutParams(width, LayoutParams.FILL_PARENT); } addTab(position, tab, params); }
From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//w w w . ja v a 2 s . c o m tab.setSingleLine(); tab.setTextColor(tabTextColor); tab.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }