List of usage examples for android.widget TextView getPaddingTop
public int getPaddingTop()
From source file:com.agenthun.readingroutine.utils.ViewUtils.java
public static void setPaddingStart(TextView target, int paddingStart) { ViewCompat.setPaddingRelative(target, paddingStart, target.getPaddingTop(), ViewCompat.getPaddingEnd(target), target.getPaddingBottom()); }
From source file:Main.java
private static void onCenterDraw(TextView view, Canvas canvas, Drawable drawable, int gravity) { int drawablePadding = view.getCompoundDrawablePadding(); int ratio = 1; float total;//from ww w .ja va2 s. co m switch (gravity) { case Gravity.END: ratio = -1; case Gravity.START: total = view.getPaint().measureText(view.getText().toString()) + drawable.getIntrinsicWidth() + drawablePadding + view.getPaddingLeft() + view.getPaddingRight(); canvas.translate(ratio * (view.getWidth() - total) / 2, 0); break; case Gravity.BOTTOM: ratio = -1; case Gravity.TOP: Paint.FontMetrics fontMetrics = view.getPaint().getFontMetrics(); total = fontMetrics.descent - fontMetrics.ascent + drawable.getIntrinsicHeight() + drawablePadding + view.getPaddingTop() + view.getPaddingBottom(); canvas.translate(0, ratio * (view.getHeight() - total) / 2); break; } }
From source file:Main.java
private static void onCenterDraw(TextView view, Canvas canvas, Drawable drawable, int gravity) { int drawablePadding = view.getCompoundDrawablePadding(); int ratio = 1; float total;//from w w w . j a v a 2 s . co m switch (gravity) { case Gravity.RIGHT: ratio = -1; case Gravity.LEFT: total = view.getPaint().measureText(view.getText().toString()) + drawable.getIntrinsicWidth() + drawablePadding + view.getPaddingLeft() + view.getPaddingRight(); canvas.translate(ratio * (view.getWidth() - total) / 2, 0); break; case Gravity.BOTTOM: ratio = -1; case Gravity.TOP: Paint.FontMetrics fontMetrics0 = view.getPaint().getFontMetrics(); total = fontMetrics0.descent - fontMetrics0.ascent + drawable.getIntrinsicHeight() + drawablePadding + view.getPaddingTop() + view.getPaddingBottom(); canvas.translate(0, ratio * (view.getHeight() - total) / 2); break; } }
From source file:Main.java
public static boolean drawDrawables(Canvas canvas, @Nonnull TextView textView) { final int compoundPaddingLeft = textView.getCompoundPaddingLeft(); final int compoundPaddingTop = textView.getCompoundPaddingTop(); final int compoundPaddingRight = textView.getCompoundPaddingRight(); final int compoundPaddingBottom = textView.getCompoundPaddingBottom(); final int scrollX = textView.getScrollX(); final int scrollY = textView.getScrollY(); final int right = textView.getRight(); final int left = textView.getLeft(); final int bottom = textView.getBottom(); final int top = textView.getTop(); final Drawable[] drawables = textView.getCompoundDrawables(); if (drawables != null) { int vspace = bottom - top - compoundPaddingBottom - compoundPaddingTop; int hspace = right - left - compoundPaddingRight - compoundPaddingLeft; Drawable topDr = drawables[1];/*from www .j a va 2 s . c o m*/ // IMPORTANT: The coordinates computed are also used in invalidateDrawable() // Make sure to update invalidateDrawable() when changing this code. if (topDr != null) { canvas.save(); canvas.translate(scrollX + compoundPaddingLeft + (hspace - topDr.getBounds().width()) / 2, scrollY + textView.getPaddingTop() + vspace / 2); topDr.draw(canvas); canvas.restore(); return true; } } return false; }
From source file:com.conferenceengineer.android.iosched.ui.TracksAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (isAllTracksItem(position)) { if (convertView == null) { convertView = mActivity.getLayoutInflater().inflate(R.layout.list_item_track, parent, false); }/* w w w . j a v a 2 s . c o m*/ // Custom binding for the first item ((TextView) convertView.findViewById(android.R.id.text1)) .setText("(" + mActivity.getResources().getString(R.string.all_tracks) + ")"); convertView.findViewById(android.R.id.icon1).setVisibility(View.INVISIBLE); return convertView; } else if (isLevel2Header(position)) { TextView view = (TextView) convertView; if (view == null) { view = (TextView) mActivity.getLayoutInflater().inflate(R.layout.list_item_track_header, parent, false); if (mIsDropDown) { Rect r = new Rect(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()); view.setBackgroundResource(R.drawable.track_header_bottom_border); view.setPadding(r.left, r.top, r.right, r.bottom); } } view.setText(R.string.other_tracks); return view; } return super.getView(adapterPositionToCursorPosition(position), convertView, parent); }
From source file:com.coreform.open.android.formidablevalidation.SetErrorHandler.java
private void chooseSize(PopupWindow pop, CharSequence text, TextView tv) { int wid = tv.getPaddingLeft() + tv.getPaddingRight(); int ht = tv.getPaddingTop() + tv.getPaddingBottom(); //com.android.internal.R.dimen.textview_error_popup_default_width introduced after Gingerbread, only has one variant (240dip) int defaultWidthInPixels = mContext.getResources() .getDimensionPixelSize(R.dimen.textview_error_popup_default_width); Layout l = new StaticLayout(text, tv.getPaint(), defaultWidthInPixels, Layout.Alignment.ALIGN_NORMAL, 1, 0, true);/*www . java 2 s . com*/ float max = 0; for (int i = 0; i < l.getLineCount(); i++) { max = Math.max(max, l.getLineWidth(i)); } if (DEBUG) Log.d(TAG, "max: " + max + ", height: " + l.getHeight()); /* * Now set the popup size to be big enough for the text plus the border. */ pop.setWidth(wid + (int) Math.ceil(max)); pop.setHeight(ht + l.getHeight()); //TODO: buggy (the 2 shouldnt need to be there) }
From source file:com.munger.passwordkeeper.view.ViewDetailFragment.java
/** * Select the textView by changing the background * An interesting feature of android is changing the background on a textview will cause the padding to get reset. * @param v the view to be selected// w ww.jav a 2s . c o m * @param selected are we selecting or deselecting the view? */ private void selectText(TextView v, boolean selected) { int left = v.getPaddingLeft(); int right = v.getPaddingRight(); int top = v.getPaddingTop(); int bott = v.getPaddingBottom(); int resid = 0; if (selected) resid = R.drawable.abc_list_selector_background_transition_holo_dark; v.setBackgroundResource(resid); v.setPadding(left, top, right, bott); }
From source file:com.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param fieldTable//from w ww.j a v a2 s .c om * @param nameOfField * @param field */ private void addConflictRow(TableLayout fieldTable, final String nameOfField, final String fieldLocal, final String fieldRemote) { if (mCurrentLocal == null || mCurrentSugar == null) return; // String fieldLocal = mCurrentLocal.get(nameOfField); // String fieldRemote = mCurrentSugar.get(nameOfField); TableRow row = new TableRow(this); final Spinner sourceSelect = new Spinner(this); sourceSelect.setBackgroundResource(R.drawable.black_underline); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, this.getResources().getStringArray(R.array.conflict_sources)); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sourceSelect.setAdapter(spinnerArrayAdapter); // Open the spinner when pressing any of the text fields OnClickListener spinnerOpener = new OnClickListener() { @Override public void onClick(View v) { sourceSelect.performClick(); } }; row.addView(sourceSelect); fieldTable.addView(row); row = new TableRow(this); TextView fieldName = new TextView(this); int stringId = this.getResources().getIdentifier(nameOfField, "string", this.getPackageName()); fieldName.setText(this.getString(stringId)); fieldName.setTextSize(16); fieldName.setPadding(fieldName.getPaddingLeft(), fieldName.getPaddingTop(), fieldName.getPaddingRight() + 10, fieldName.getPaddingBottom()); fieldName.setOnClickListener(spinnerOpener); row.addView(fieldName); final TextView fieldValueLocal = new TextView(this); fieldValueLocal.setText(fieldLocal); fieldValueLocal.setTextSize(16); row.addView(fieldValueLocal); fieldValueLocal.setOnClickListener(spinnerOpener); fieldTable.addView(row); row = new TableRow(this); row.addView(new TextView(this));// add dummy control final TextView fieldValueRemote = new TextView(this); fieldValueRemote.setText(fieldRemote); fieldValueRemote.setTextSize(16); fieldValueRemote.setOnClickListener(spinnerOpener); row.addView(fieldValueRemote); sourceSelect.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); resolvedContacts[mPosResolved].set(nameOfField, fieldLocal); } else { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); resolvedContacts[mPosResolved].set(nameOfField, fieldRemote); } } @Override public void onNothingSelected(AdapterView<?> view) { } }); row.setPadding(row.getLeft(), row.getTop() + 5, row.getRight(), row.getBottom() + 10); // Restore appropiate selections according to resolved contact if (resolvedContacts[mPosResolved].get(nameOfField).equals(fieldLocal)) { sourceSelect.setSelection(0); } else { sourceSelect.setSelection(1); } fieldTable.addView(row); }
From source file:dcheungaa.procal.MainActivity.java
@Override public void onWindowFocusChanged(boolean hasFocus) { TextView cursor = (TextView) MainActivity.views.get("cursor"); TextView matrixDisplay = (TextView) MainActivity.views.get("matrixDisplay"); super.onWindowFocusChanged(hasFocus); if (call_load) { call_load = false;/*from w w w. ja v a 2s. c o m*/ fontWidth = cursor.getWidth(); fontHeight = cursor.getHeight(); cursor.setText(Character.toString((char) 0x258E)); //cursor.setTop(matrixDisplay.getTop()); cursor.setPadding(matrixDisplay.getPaddingLeft(), cursor.getPaddingTop(), cursor.getPaddingRight(), cursor.getPaddingBottom()); cursor.setLeft(matrixDisplay.getLeft()); //CursorHandler.hideCursor(); RelativeLayout cm = (RelativeLayout) findViewById(R.id.content_main); LinearLayout rows = (LinearLayout) findViewById(R.id.llKeyPad); keyPad.KeyPad_resize(cm, rows); int fnBtnHeight = keyPad.btn_rows.get(0).get(0).get_mheight(); System.out.print(Integer.toString(fnBtnHeight)); varPad.resize(fnBtnHeight, fnBtnHeight * 3, svVar); cmdPad.resize(fnBtnHeight, fnBtnHeight * 3, svCmd); constPad.resize(fnBtnHeight, fnBtnHeight * 3, svConst); } }
From source file:com.community.yuequ.bottombar.BottomBar.java
private void updateTitleBottomPadding() { if (tabContainer == null) { return;// w w w . j a v a2 s. co m } int childCount = getTabCount(); for (int i = 0; i < childCount; i++) { View tab = tabContainer.getChildAt(i); TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title); if (title == null) { continue; } int baseline = title.getBaseline(); int height = title.getHeight(); int paddingInsideTitle = height - baseline; int missingPadding = tenDp - paddingInsideTitle; if (missingPadding > 0) { title.setPadding(title.getPaddingLeft(), title.getPaddingTop(), title.getPaddingRight(), missingPadding + title.getPaddingBottom()); } } }