List of usage examples for android.widget TextView getTextSize
@ViewDebug.ExportedProperty(category = "text") public float getTextSize()
From source file:de.androvdr.fragments.EpgsdataFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.epgsdata_fragment, container, false); TextView tv = (TextView) root.findViewById(R.id.header_text); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (tv.getTextSize() / getResources().getDisplayMetrics().scaledDensity) + Preferences.textSizeOffset); mView = (LinearLayout) root.findViewById(R.id.epgsdata_main); return root;/*from w ww. j av a2 s .c o m*/ }
From source file:com.agenthun.readingroutine.utils.TextSharedElementCallback.java
@Override public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { TextView targetView = getTextView(sharedElements); if (targetView == null) { Log.w(TAG, "onSharedElementStart: No shared TextView, skipping."); return;//from www . j av a 2 s . c o m } mTargetViewTextSize = targetView.getTextSize(); mTargetViewPaddingStart = targetView.getPaddingStart(); // Setup the TextView's start values. targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mInitialTextSize); ViewUtils.setPaddingStart(targetView, mInitialPaddingStart); }
From source file:de.androvdr.fragments.RecordingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.recordings_fragment, container, false); float sd = getResources().getDisplayMetrics().scaledDensity; TextView tv = (TextView) root.findViewById(R.id.header_text); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (tv.getTextSize() / sd) + Preferences.textSizeOffset); tv.setText(R.string.rec_recordings); tv = (TextView) root.findViewById(R.id.recdiskstatus_values); if (tv != null) tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (tv.getTextSize() / sd) + Preferences.textSizeOffset); return root;// w w w.ja va 2 s . c o m }
From source file:com.fastbootmobile.encore.utils.Utils.java
/** * Calculates the optimal size of the text based on the text view width * * @param textView The text view in which the text should fit * @param desiredWidth The desired final text width, or -1 for the TextView's getMeasuredWidth *//*from ww w . java2s . co m*/ public static void adjustTextSize(TextView textView, int desiredWidth) { if (desiredWidth <= 0) { desiredWidth = textView.getMeasuredWidth(); if (desiredWidth <= 0) { // Invalid width, don't do anything Log.w("Utils", "adjustTextSize: Not doing anything (measured width invalid)"); return; } } // Add some margin to width desiredWidth *= 0.8f; Paint paint = new Paint(); Rect bounds = new Rect(); paint.setTypeface(textView.getTypeface()); float textSize = textView.getTextSize() * 2.0f; paint.setTextSize(textSize); String text = textView.getText().toString(); paint.getTextBounds(text, 0, text.length(), bounds); while (bounds.width() > desiredWidth) { textSize--; paint.setTextSize(textSize); paint.getTextBounds(text, 0, text.length(), bounds); } textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); }
From source file:de.androvdr.fragments.TimersFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.timers_fragment, container, false); TextView tv = (TextView) root.findViewById(R.id.header_text); tv.setText(R.string.timers);// ww w . j a v a 2 s . c o m tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (tv.getTextSize() / getResources().getDisplayMetrics().scaledDensity) + Preferences.textSizeOffset); return root; }
From source file:de.androvdr.fragments.ChannelsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.extendedchannels_fragment, container, false); float sd = getResources().getDisplayMetrics().scaledDensity; TextView tv = (TextView) root.findViewById(R.id.header_text); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (tv.getTextSize() / sd) + Preferences.textSizeOffset); tv.setText(R.string.channels);/*from ww w . j a va2 s . c om*/ tv = (TextView) root.findViewById(R.id.footer_text); if (tv != null) tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (tv.getTextSize() / sd) + Preferences.textSizeOffset); return root; }
From source file:it.scoppelletti.mobilepower.preference.ColorPreference.java
@Override protected Spannable.Factory newSummarySpannableFactory(TextView summaryControl) { return new ColorPreference.SummarySpannableFactory(this, (int) summaryControl.getTextSize()); }
From source file:com.android.deskclock.timer.TimerView.java
/** * Measure the text and add a start padding to the view * @param textView view to measure and onb to which add start padding *//* www. j a v a2s. c o m*/ private void addStartPadding(TextView textView) { final float gapPadding = 0.45f; // allDigits will contain ten digits: "0123456789" in the default locale String allDigits = String.format(Locale.getDefault(), "%010d", 123456789); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setTextSize(textView.getTextSize()); paint.setTypeface(textView.getTypeface()); float widths[] = new float[allDigits.length()]; int ll = paint.getTextWidths(allDigits, widths); int largest = 0; for (int ii = 1; ii < ll; ii++) { if (widths[ii] > widths[largest]) { largest = ii; } } // Add left padding to the view - Note: layout inherits LTR textView.setPadding((int) (gapPadding * widths[largest]), 0, 0, 0); }
From source file:com.mimp.fragment.institucion.PlanTrabajoPage.java
public void btnAgregar() { final Dialog dialog = new Dialog(this.getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); //dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_plan_trabajo); TextView lblResponsable = (TextView) dialog.findViewById(R.id.lblResponsable); lblResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblResponsable.getTextSize() + SizeText); TextView lblDResponsable = (TextView) dialog.findViewById(R.id.lblDResponsable); lblDResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblDResponsable.getTextSize() + SizeText); TextView lblObejtivo = (TextView) dialog.findViewById(R.id.lblObejtivo); lblObejtivo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblObejtivo.getTextSize() + SizeText); TextView lblMeta = (TextView) dialog.findViewById(R.id.lblMeta); lblMeta.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblMeta.getTextSize() + SizeText); TextView lblActividad = (TextView) dialog.findViewById(R.id.lblActividad); lblActividad.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblActividad.getTextSize() + SizeText); TextView lblCronograma = (TextView) dialog.findViewById(R.id.lblCronograma); lblCronograma.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblCronograma.getTextSize() + SizeText); final EditText txtObejtivo = (EditText) dialog.findViewById(R.id.txtObejtivo); txtObejtivo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtObejtivo.getTextSize() + SizeText); txtObejtivo.setText(""); final EditText txtActividad = (EditText) dialog.findViewById(R.id.txtActividad); txtActividad.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtActividad.getTextSize() + SizeText); txtActividad.setText(""); final EditText txtCronograma = (EditText) dialog.findViewById(R.id.txtCronograma); txtCronograma.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtCronograma.getTextSize() + SizeText); txtCronograma.setText(""); final EditText txtMeta = (EditText) dialog.findViewById(R.id.txtMeta); txtMeta.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtMeta.getTextSize() + SizeText); txtMeta.setText(""); final EditText txtResponsable = (EditText) dialog.findViewById(R.id.txtResponsable); txtResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtResponsable.getTextSize() + SizeText); txtResponsable.setText(""); Button btnAgregar = (Button) dialog.findViewById(R.id.btnAgregar); btnAgregar.setOnClickListener(new View.OnClickListener() { @Override// w ww. j a va2s . co m public void onClick(View v) { clsPlanTrabajo entidad = new clsPlanTrabajo(); entidad.setActividad(txtActividad.getText().toString()); entidad.setCronograma(txtCronograma.getText().toString()); entidad.setMeta(txtMeta.getText().toString()); entidad.setObejtivo(txtObejtivo.getText().toString()); entidad.setResponsable(txtResponsable.getText().toString()); list.add(entidad); getListaPlanTrabajo(); dialog.dismiss(); } }); dialog.show(); }
From source file:org.chaos.fx.cnbeta.details.DetailsFragment.java
private void scaleTextSize(TextView v, float relativeSize) { v.setTextSize(TypedValue.COMPLEX_UNIT_PX, v.getTextSize() * relativeSize); }