List of usage examples for android.view Gravity CENTER_VERTICAL
int CENTER_VERTICAL
To view the source code for android.view Gravity CENTER_VERTICAL.
Click Source Link
From source file:com.mb.kids_mind.GcmIntentService.java
public void ToastAll(Context context, String msg) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast_layout, null); Toast mToast = new Toast(context.getApplicationContext()); mToast.setGravity(Gravity.CENTER_VERTICAL, 0, 2); mToast.setDuration(Toast.LENGTH_SHORT); mToast.setView(layout);//www . j ava2 s. c om if (flag == false) { flag = true; mToast.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { flag = false; } }, 2000);// ? ?? 2 . } else { Log.e("", " ?"); } }
From source file:com.drjane.promise.ui.fragment.CalendarFragment.java
private void initGridView() { // ??/*from ww w. j a v a 2 s . c o m*/ WindowManager windowManager = getActivity().getWindowManager(); Display display = windowManager.getDefaultDisplay(); int Width = display.getWidth(); int Height = display.getHeight(); mGridView = new CustomGridView(getActivity()); mGridView.setNumColumns(7); mGridView.setColumnWidth(40); // gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); if (Width == 720 && Height == 1280) { mGridView.setColumnWidth(40); } mGridView.setGravity(Gravity.CENTER_VERTICAL); mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); // gridView mGridView.setVerticalSpacing(1); mGridView.setHorizontalSpacing(1); mHandler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub mGridView.setAdapter(calendarGridViewAdapter); } }); }
From source file:com.example.drugsformarinemammals.Combined_Search.java
private void displayMessage(String messageTitle, String message) { AlertDialog.Builder myalert = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setTypeface(Typeface.SANS_SERIF); title.setTextSize(20);//from w ww. j ava 2s. c o m title.setTextColor(getResources().getColor(R.color.blue)); title.setPadding(8, 8, 8, 8); title.setText(messageTitle); title.setGravity(Gravity.CENTER_VERTICAL); LinearLayout layout = new LinearLayout(this); TextView text = new TextView(this); text.setTypeface(Typeface.SANS_SERIF); text.setTextSize(20); text.setPadding(10, 10, 10, 10); text.setText(message); layout.addView(text); myalert.setView(layout); myalert.setCustomTitle(title); myalert.setCancelable(true); myalert.show(); }
From source file:com.tmall.ultraviewpager.UltraViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (viewPager == null || viewPager.getAdapter() == null) return;// w w w.j av a 2 s .c o m final int count = ((UltraViewPagerAdapter) viewPager.getAdapter()).getRealCount(); if (count == 0) return; int longSize; int shortSize; int longPaddingBefore; int longPaddingAfter; int shortPaddingBefore; int shortPaddingAfter; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longSize = viewPager.getWidth(); shortSize = viewPager.getHeight(); longPaddingBefore = getPaddingLeft() + marginLeft; longPaddingAfter = getPaddingRight() + marginRight; shortPaddingBefore = getPaddingTop() + marginTop; shortPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; } else { longSize = viewPager.getHeight(); shortSize = viewPager.getWidth(); longPaddingBefore = getPaddingTop() + marginTop; longPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; shortPaddingBefore = getPaddingLeft() + marginLeft; shortPaddingAfter = getPaddingRight() + marginRight; } final float itemWidth = getItemWidth(); final int widthRatio = isDrawResIndicator() ? 1 : 2; //bitmap resource X1 : circle X2 if (indicatorPadding == 0) { indicatorPadding = (int) itemWidth; } float shortOffset = shortPaddingBefore; float longOffset = longPaddingBefore; final float indicatorLength = (count - 1) * (itemWidth * widthRatio + indicatorPadding); final int horizontalGravityMask = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int verticalGravityMask = gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (horizontalGravityMask) { case Gravity.CENTER_HORIZONTAL: longOffset = (longSize - longPaddingBefore - longPaddingAfter - indicatorLength) / 2.0f; break; case Gravity.RIGHT: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longOffset = longSize - longPaddingAfter - indicatorLength - itemWidth; } if (orientation == UltraViewPager.Orientation.VERTICAL) { shortOffset = shortSize - shortPaddingAfter - itemWidth; } break; case Gravity.LEFT: longOffset += itemWidth; default: break; } switch (verticalGravityMask) { case Gravity.CENTER_VERTICAL: shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; break; case Gravity.BOTTOM: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { shortOffset = shortSize - shortPaddingAfter - getItemHeight(); } if (orientation == UltraViewPager.Orientation.VERTICAL) { longOffset = longSize - longPaddingAfter - indicatorLength; } break; case Gravity.TOP: shortOffset += itemWidth; default: break; } if (horizontalGravityMask == Gravity.CENTER_HORIZONTAL && verticalGravityMask == Gravity.CENTER_VERTICAL) { shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; } float dX; float dY; float pageFillRadius = radius; if (paintStroke.getStrokeWidth() > 0) { pageFillRadius -= paintStroke.getStrokeWidth() / 2.0f; //TODO may not/2 } //Draw stroked circles for (int iLoop = 0; iLoop < count; iLoop++) { float drawLong = longOffset + (iLoop * (itemWidth * widthRatio + indicatorPadding)); if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = drawLong; dY = shortOffset; } else { dX = shortOffset; dY = drawLong; } if (isDrawResIndicator()) { if (iLoop == viewPager.getCurrentItem()) continue; canvas.drawBitmap(normalBitmap, dX, dY, paintFill); } else { // Only paint fill if not completely transparent if (paintFill.getAlpha() > 0) { paintFill.setColor(normalColor); canvas.drawCircle(dX, dY, pageFillRadius, paintFill); } // Only paint stroke if a stroke width was non-zero if (pageFillRadius != radius) { canvas.drawCircle(dX, dY, radius, paintStroke); } } } //Draw the filled circle according to the current scroll float cx = (viewPager.getCurrentItem()) * (itemWidth * widthRatio + indicatorPadding); if (animateIndicator) cx += pageOffset * itemWidth; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = longOffset + cx; dY = shortOffset; } else { dX = shortOffset; dY = longOffset + cx; } if (isDrawResIndicator()) { canvas.drawBitmap(focusBitmap, dX, dY, paintStroke); } else { paintFill.setColor(focusColor); canvas.drawCircle(dX, dY, radius, paintFill); } }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private TextView title() { TextView title = new TextView(context); title.setSingleLine();//from w ww . j ava 2 s . c o m title.setEllipsize(TruncateAt.END); title.setMaxWidth(UZCoreUtil.dipToPix(maxWidth) - 2 * iconMarginLeft + iconSize); title.setText(getTitle()); title.setTextColor(getTitleColor()); title.setTextSize(getTitleSize()); title.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); return title; }
From source file:com.qs.qswlw.view.Mypager.UltraViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (viewPager == null || viewPager.getAdapter() == null) return;/*from w ww . j av a 2s.co m*/ final int count = ((UltraViewPagerAdapter) viewPager.getAdapter()).getRealCount(); if (count == 0) return; int longSize; int shortSize; int longPaddingBefore; int longPaddingAfter; int shortPaddingBefore; int shortPaddingAfter; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longSize = viewPager.getWidth(); shortSize = viewPager.getHeight(); longPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft); longPaddingAfter = getPaddingRight() + marginRight; shortPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop); shortPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; } else { longSize = viewPager.getHeight(); shortSize = viewPager.getWidth(); longPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop); longPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; shortPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft); shortPaddingAfter = getPaddingRight() + marginRight; } final float itemWidth = getItemWidth(); final int widthRatio = isDrawResIndicator() ? 1 : 2; //bitmap resource X1 : circle X2 if (indicatorPadding == 0) { indicatorPadding = (int) itemWidth; } float shortOffset = shortPaddingBefore; float longOffset = longPaddingBefore; final float indicatorLength = count * itemWidth * widthRatio + (count - 1) * indicatorPadding; final int horizontalGravityMask = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int verticalGravityMask = gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (horizontalGravityMask) { case Gravity.CENTER_HORIZONTAL: longOffset = (longSize - longPaddingBefore - longPaddingAfter - indicatorLength) / 2.0f; break; case Gravity.RIGHT: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longOffset = longSize - longPaddingAfter - indicatorLength; } if (orientation == UltraViewPager.Orientation.VERTICAL) { shortOffset = shortSize - shortPaddingAfter - itemWidth; } break; case Gravity.LEFT: default: break; } switch (verticalGravityMask) { case Gravity.CENTER_VERTICAL: shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; break; case Gravity.BOTTOM: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { shortOffset = shortSize - shortPaddingAfter - getItemHeight(); } if (orientation == UltraViewPager.Orientation.VERTICAL) { longOffset = longSize - longPaddingAfter - indicatorLength; } break; case Gravity.TOP: default: break; } if (horizontalGravityMask == Gravity.CENTER_HORIZONTAL && verticalGravityMask == Gravity.CENTER_VERTICAL) { shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; } float dX; float dY; float pageFillRadius = radius; if (paintStroke.getStrokeWidth() > 0) { pageFillRadius -= paintStroke.getStrokeWidth() / 2.0f; //TODO may not/2 } //Draw stroked circles for (int iLoop = 0; iLoop < count; iLoop++) { float drawLong = longOffset + (iLoop * (itemWidth * widthRatio + indicatorPadding)); if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = drawLong; dY = shortOffset; } else { dX = shortOffset; dY = drawLong; } if (isDrawResIndicator()) { if (iLoop == viewPager.getCurrentItem()) continue; canvas.drawBitmap(normalBitmap, dX, dY, paintFill); } else { // Only paint fill if not completely transparent if (paintFill.getAlpha() > 0) { paintFill.setColor(normalColor); canvas.drawCircle(dX, dY, pageFillRadius, paintFill); } // Only paint stroke if a stroke width was non-zero if (pageFillRadius != radius) { canvas.drawCircle(dX, dY, radius, paintStroke); } } } //Draw the filled circle according to the current scroll float cx = (viewPager.getCurrentItem()) * (itemWidth * widthRatio + indicatorPadding); if (animateIndicator) cx += pageOffset * itemWidth; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = longOffset + cx; dY = shortOffset; } else { dX = shortOffset; dY = longOffset + cx; } if (isDrawResIndicator()) { canvas.drawBitmap(focusBitmap, dX, dY, paintStroke); } else { paintFill.setColor(focusColor); canvas.drawCircle(dX, dY, radius, paintFill); } }
From source file:widgets.Graphical_Binary_New.java
public Graphical_Binary_New(tracerengine Trac, Activity context, String address, String name, int id, int dev_id, String state_key, String url, final String usage, String parameters, String model_id, int update, int widgetSize, int session_type, int place_id, String place_type, SharedPreferences params) throws JSONException { super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container); this.Tracer = Trac; this.context = context; this.address = address; this.url = url; this.state_key = state_key; this.dev_id = dev_id; this.id = id; this.usage = usage; this.update = update; this.name = name; this.wname = name; this.myself = this; this.session_type = session_type; this.stateS = getResources().getText(R.string.State).toString(); this.place_id = place_id; this.place_type = place_type; this.params = params; login = params.getString("http_auth_username", null); password = params.getString("http_auth_password", null); mytag = "Graphical_Binary_New(" + dev_id + ")"; //get parameters try {/*from w w w .j a v a 2 s . co m*/ JSONObject jparam = new JSONObject(parameters.replaceAll(""", "\"")); value0 = jparam.getString("value0"); value1 = jparam.getString("value1"); } catch (Exception e) { value0 = "0"; value1 = "1"; } if (usage.equals("light")) { this.Value_0 = getResources().getText(R.string.light_stat_0).toString(); this.Value_1 = getResources().getText(R.string.light_stat_1).toString(); } else if (usage.equals("shutter")) { this.Value_0 = getResources().getText(R.string.shutter_stat_0).toString(); this.Value_1 = getResources().getText(R.string.shutter_stat_1).toString(); } else { this.Value_0 = value0; this.Value_1 = value1; } String[] model = model_id.split("\\."); type = model[0]; Tracer.d(mytag, "model_id = <" + model_id + "> type = <" + type + "> value0 = " + value0 + " value1 = " + value1); //state state = new TextView(context); state.setTextColor(Color.BLACK); state.setText("State :" + this.Value_0); final float scale = getContext().getResources().getDisplayMetrics().density; float dps = 40; int pixels = (int) (dps * scale + 0.5f); //first seekbar on/off ON = new Button(context); ON.setOnClickListener(this); ON.setHeight(pixels); //ON.setWidth(60); ON.setTag("ON"); ON.setText(this.Value_1); ON.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); //ON.setBackgroundResource(R.drawable.boolean_on); //ON.setPadding(10, 0, 10, 0); OFF = new Button(context); OFF.setOnClickListener(this); OFF.setTag("OFF"); OFF.setHeight(pixels); //OFF.setWidth(60); OFF.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); //OFF.setBackgroundResource(R.drawable.boolean_off); OFF.setText(this.Value_0); //OFF.setPadding(0,10,0,10); super.LL_featurePan.addView(ON); super.LL_featurePan.addView(OFF); super.LL_infoPan.addView(state); handler = new Handler() { @Override public void handleMessage(Message msg) { if (activate) { Tracer.d(mytag, "Handler receives a request to die "); if (realtime) { Tracer.get_engine().unsubscribe(session); session = null; realtime = false; } //That seems to be a zombie //removeView(background); myself.setVisibility(GONE); if (container != null) { container.removeView(myself); container.recomputeViewAttributes(myself); } try { finalize(); } catch (Throwable t) { } //kill the handler thread itself } else { try { Bundle b = msg.getData(); if ((b != null) && (b.getString("message") != null)) { if (b.getString("message").equals(value0)) { //state.setText(stateS+value0); state.setText(stateS + Value_0); IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 0)); } else if (b.getString("message").equals(value1)) { //state.setText(stateS+value1); state.setText(stateS + Value_1); IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 2)); } state.setAnimation(animation); } else { if (msg.what == 2) { Toast.makeText(getContext(), "Command Failed", Toast.LENGTH_SHORT).show(); } else if (msg.what == 9999) { //state_engine send us a signal to notify value changed if (session == null) return; String new_val = session.getValue(); Tracer.d(mytag, "Handler receives a new value <" + new_val + ">"); if (new_val.equals(value0)) { state.setText(stateS + Value_0); IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 0)); } else if (new_val.equals(value1)) { state.setText(stateS + Value_1); IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 2)); } else { state.setText(stateS + new_val); } } else if (msg.what == 9998) { // state_engine send us a signal to notify it'll die ! Tracer.d(mytag, "state engine disappeared ===> Harakiri !"); session = null; realtime = false; //removeView(background); myself.setVisibility(GONE); if (container != null) { container.removeView(myself); container.recomputeViewAttributes(myself); } try { finalize(); } catch (Throwable t) { } //kill the handler thread itself } } } catch (Exception e) { Tracer.e(mytag, "Handler error for device " + wname); e.printStackTrace(); } } } }; //================================================================================ /* * New mechanism to be notified by widgetupdate engine when our value is changed * */ WidgetUpdate cache_engine = WidgetUpdate.getInstance(); if (cache_engine != null) { session = new Entity_client(dev_id, state_key, mytag, handler, session_type); if (Tracer.get_engine().subscribe(session)) { realtime = true; //we're connected to engine //each time our value change, the engine will call handler handler.sendEmptyMessage(9999); //Force to consider current value in session } } //================================================================================ //updateTimer(); //Don't use anymore cyclic refresh.... }
From source file:net.evecom.androidecssp.activity.event.ContinueInfoActivity.java
/** * //w ww. j av a 2 s .c o m * * * @author Stark Zhou * @created 2015-12-30 3:03:36 */ private void initGallery() { mGallery = (GalleryFlow) findViewById(R.id.continue_gallery_flow); mGallery.setBackgroundColor(Color.parseColor("#ffffff")); // mGallery.setSpacing(90);// mGallery.setMaxRotationAngle(20);// mGallery.setFadingEdgeLength(10); // mGallery.setGravity(Gravity.CENTER_VERTICAL); // mGallery.setAdapter(new GalleryAdapter()); mGallery.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(getApplicationContext(), AfnailPictureActivity.class); BaseActivity.pushObjData("filebean", filebeans.get(position), intent); startActivityForResult(intent, R.layout.afnail_picture_activity); } }); }
From source file:com.github.shareme.gwsmaterialuikit.library.material.app.SimpleDialog.java
private void initMessageView() { mMessage = new TextView(getContext()); mMessage.setTextAppearance(getContext(), mMessageTextAppearanceId); mMessage.setTextColor(mMessageTextColor); mMessage.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); }
From source file:com.ape.cloudfile.widget.vpi.TabPageIndicator.java
private void addTab(int index, CharSequence text, int iconResId, int count) { final TabView tabView = new TabView(getContext()); tabView.mIndex = index;// ww w . j a va2 s.c o m tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); tabView.setGravity(Gravity.CENTER); tabView.setPadding(0, 15, 0, 15); tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); tabView.setTextColor(getResources().getColorStateList(R.color.myos_tab_text_color)); // if (iconResId != 0) { // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0); // } if (count > 1) { tabView.setBackgroundResource(R.drawable.action_tab_background); } else { tabView.setBackgroundResource(R.drawable.tinno_title_bg_holo_light); tabView.setTextColor(getResources().getColor(R.color.tab_bar_title_color)); tabView.setPadding(20, 0, 0, 0); tabView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); Drawable drawable = getResources().getDrawable(R.drawable.title_panel_back); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); tabView.setCompoundDrawables(drawable, null, null, null); } //add by zjw // if(index == 0) // { // tabView.setBackgroundResource(R.drawable.title_bar_left_selector); // }else if(index == (count - 1)) // { // tabView.setBackgroundResource(R.drawable.title_bar_right_selector); // }else // { // tabView.setBackgroundResource(R.drawable.title_bar_middle_selector); // } mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1)); }