List of usage examples for android.widget TextView getTextSize
@ViewDebug.ExportedProperty(category = "text") public float getTextSize()
From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java
private boolean recurseGroup(Context context, ViewGroup gp) { final int count = gp.getChildCount(); for (int i = 0; i < count; ++i) { if (gp.getChildAt(i) instanceof TextView) { final TextView text = (TextView) gp.getChildAt(i); final String szText = text.getText().toString(); if (COLOR_SEARCH_RECURSE_TIP.equals(szText)) { notification_text_color = text.getTextColors().getDefaultColor(); notification_text_size = text.getTextSize(); DisplayMetrics metrics = new DisplayMetrics(); WindowManager systemWM = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); systemWM.getDefaultDisplay().getMetrics(metrics); notification_text_size /= metrics.scaledDensity; return true; }//from w w w .j a v a2 s . c o m } else if (gp.getChildAt(i) instanceof ViewGroup) return recurseGroup((Context) context, (ViewGroup) gp.getChildAt(i)); } return false; }
From source file:org.videolan.myvlc.core.gui.about.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about);//from www . jav a 2 s . c o m displayVersionName(); mMainFragment = new AboutMainFragment(); mLicenceFragment = new AboutLicenceFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(android.R.id.tabcontent, mMainFragment); ft.add(android.R.id.tabcontent, mLicenceFragment); ft.commit(); DummyContentFactory dcf = new DummyContentFactory(this); mTabHost = (TabHost) findViewById(R.id.about_tabhost); mTabHost.setup(); TabHost.TabSpec tab_main = mTabHost.newTabSpec("main"); tab_main.setContent(dcf); tab_main.setIndicator(getResources().getText(R.string.about)); mTabHost.addTab(tab_main); TabHost.TabSpec tab_licence = mTabHost.newTabSpec("licence"); tab_licence.setContent(dcf); tab_licence.setIndicator(getResources().getText(R.string.licence)); mTabHost.addTab(tab_licence); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView tv = (TextView) mTabHost.getTabWidget().getChildTabViewAt(i).findViewById(android.R.id.title); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); //android.util.Log.d(TAG, "TextSize = " + ((Float)tv.getTextSize()).toString()); // Scale the tab height to the text size on the device and leave enough space mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = (int) (tv.getTextSize() * 2.21); } mTabHost.setOnTabChangedListener(this); this.onTabChanged("main"); if (savedInstanceState != null) { mTabHost.setCurrentTab(savedInstanceState.getInt(CURRENT_TAB_ID)); this.onTabChanged(savedInstanceState.getString(CURRENT_TAB_TAG)); } }
From source file:com.viewpagerindicator.TabMovablePageIndicator.java
private void moveIndicator(TextView tabView) { int left = tabView.getLeft(); int width = tabView.getWidth(); int textWidth = getTextWidth(tabView.getText().toString(), tabView.getTextSize(), tabView.getTypeface()); int x = left + (width - textWidth) / 2; LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(textWidth, mIndicator.getLayoutParams().height); lp.leftMargin = x;/*w w w . ja v a 2 s . c o m*/ mIndicator.setLayoutParams(lp); }
From source file:com.gsbabil.antitaintdroid.UtilityFunctions.java
public int captureBitmapCache(String in) { TextView tv = (TextView) MyApp.context.findViewById(R.id.ocrTextview); String tvText = tv.getText().toString(); float tvTextSize = tv.getTextSize(); int tvColor = tv.getCurrentTextColor(); Bitmap bitmap = null;//from w w w . j a va 2s . co m tv.setTextSize(36); tv.setTextColor(Color.CYAN); tv.setTypeface(Typeface.SANS_SERIF); tv.setText(in); while (bitmap == null) { // http://stackoverflow.com/questions/2339429/android-view-getdrawingcache-returns-null-only-null tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); tv.setDrawingCacheEnabled(true); tv.buildDrawingCache(true); bitmap = Bitmap.createBitmap(tv.getDrawingCache()); tv.destroyDrawingCache(); tv.setDrawingCacheEnabled(false); } FileOutputStream fos = null; int res = -1; try { fos = new FileOutputStream(currentDirectory() + "/files/" + MyApp.SCREENSHOT_FILENAME); if (fos != null) { bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos); fos.close(); res = 0; } } catch (Throwable e) { Log.i(MyApp.TAG, e.getMessage().toString()); res = -1; } tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvTextSize); tv.setTypeface(Typeface.MONOSPACE); tv.setText(tvText); tv.setTextColor(tvColor); return res; }
From source file:com.example.gaurav.calculator.Calculator.java
@Override public void onTextSizeChanged(final TextView textView, float oldSize) { if (mCurrentState != CalculatorState.INPUT) { // Only animate text changes that occur from user input. return;//from w w w. j a va 2 s .c om } // Calculate the values needed to perform the scale and translation animations, // maintaining the same apparent baseline for the displayed text. final float textScale = oldSize / textView.getTextSize(); final float translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - ViewCompat.getPaddingEnd(textView)); final float translationY = (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(textView, "scaleX", textScale, 1.0f), ObjectAnimator.ofFloat(textView, "scaleY", textScale, 1.0f), ObjectAnimator.ofFloat(textView, "translationX", translationX, 0.0f), ObjectAnimator.ofFloat(textView, "translationY", translationY, 0.0f)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.start(); }
From source file:com.hamzahrmalik.calculator2.Calculator.java
@Override public void onTextSizeChanged(final TextView textView, float oldSize) { if (mCurrentState != CalculatorState.INPUT) { // Only animate text changes that occur from user input. return;// ww w.j a v a2 s . c o m } // Calculate the values needed to perform the scale and translation // animations, // maintaining the same apparent baseline for the displayed text. final float textScale = oldSize / textView.getTextSize(); final float translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd()); final float translationY = (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f), ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f), ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f), ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.start(); }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
private void initZoomControls() { // Add zoom controls final TextView tx = (TextView) findViewById(R.id.textView1); // tx.setMovementMethod(LinkMovementMethod.getInstance()); final float minm = tx.getTextSize(); final float maxm = (minm + 24); ZoomControls zoom = (ZoomControls) findViewById(R.id.zoomControls1); zoom.setOnZoomInClickListener(new OnClickListener() { @Override//from w w w. j a v a 2 s .c om public void onClick(View v) { if (tx.getTextSize() < maxm) { tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, tx.getTextSize() + 2); SharedPreferences textsize = getSharedPreferences("textS", 0); SharedPreferences.Editor editor = textsize.edit(); editor.putFloat("size", tx.getTextSize()); editor.commit(); } } }); zoom.setOnZoomOutClickListener(new OnClickListener() {// to the default // size @Override public void onClick(View v) { if (tx.getTextSize() > minm) tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, tx.getTextSize() - 2); SharedPreferences textsize = getSharedPreferences("textS", 0); SharedPreferences.Editor editor = textsize.edit(); editor.putFloat("size", tx.getTextSize()); editor.commit(); } }); }
From source file:com.juick.android.JuickMessagesAdapter.java
public static float getDefaultTextSize(Context context) { if (defaultTextSize == 0) { TextView textView = new TextView(context); defaultTextSize = textView.getTextSize(); }//from w ww . j a va2s .c o m return defaultTextSize; }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static String getDefaultFontSize(final Context context) { String size = "15.0px"; TextView tv = new TextView(context); if (tv != null) { size = String.valueOf(tv.getTextSize()) + "px"; tv = null;/*from w ww .ja v a 2s.c o m*/ } return size; }
From source file:com.android.mail.browse.ConversationItemViewCoordinates.java
private ConversationItemViewCoordinates(final Context context, final Config config, final CoordinatesCache cache) { Utils.traceBeginSection("CIV coordinates constructor"); final Resources res = context.getResources(); final int layoutId = R.layout.conversation_item_view; ViewGroup view = (ViewGroup) cache.getView(layoutId); if (view == null) { view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null); cache.put(layoutId, view);// ww w .j a va 2s. co m } // Show/hide optional views before measure/layout call final TextView folders = (TextView) view.findViewById(R.id.folders); folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE); View contactImagesView = view.findViewById(R.id.contact_image); switch (config.getGadgetMode()) { case GADGET_CONTACT_PHOTO: contactImagesView.setVisibility(View.VISIBLE); break; case GADGET_CHECKBOX: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; default: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; } final View replyState = view.findViewById(R.id.reply_state); replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE); final View personalIndicator = view.findViewById(R.id.personal_indicator); personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE); setFramePadding(context, view, config.useFullPadding()); // Layout the appropriate view. ViewCompat.setLayoutDirection(view, config.getLayoutDirection()); final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY); final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); view.measure(widthSpec, heightSpec); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); // Once the view is measured, let's calculate the dynamic width variables. folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0); folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion) / 100.0); // Utils.dumpViewTree((ViewGroup) view); // Records coordinates. // Contact images view if (contactImagesView != null) { contactImagesWidth = contactImagesView.getWidth(); contactImagesHeight = contactImagesView.getHeight(); contactImagesX = getX(contactImagesView); contactImagesY = getY(contactImagesView); } else { contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0; } final boolean isRtl = ViewUtils.isViewRtl(view); final View star = view.findViewById(R.id.star); final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start); starX = getX(star) + (isRtl ? 0 : starPadding); starY = getY(star); starWidth = star.getWidth(); final TextView senders = (TextView) view.findViewById(R.id.senders); final int sendersTopAdjust = getLatinTopAdjustment(senders); sendersX = getX(senders); sendersY = getY(senders) + sendersTopAdjust; sendersWidth = senders.getWidth(); sendersHeight = senders.getHeight(); sendersLineCount = SINGLE_LINE; sendersFontSize = senders.getTextSize(); final TextView subject = (TextView) view.findViewById(R.id.subject); final int subjectTopAdjust = getLatinTopAdjustment(subject); subjectX = getX(subject); subjectY = getY(subject) + subjectTopAdjust; subjectWidth = subject.getWidth(); subjectHeight = subject.getHeight(); subjectFontSize = subject.getTextSize(); final TextView snippet = (TextView) view.findViewById(R.id.snippet); final int snippetTopAdjust = getLatinTopAdjustment(snippet); snippetX = getX(snippet); snippetY = getY(snippet) + snippetTopAdjust; maxSnippetWidth = snippet.getWidth(); snippetHeight = snippet.getHeight(); snippetFontSize = snippet.getTextSize(); if (config.areFoldersVisible()) { foldersLeft = getX(folders); foldersRight = foldersLeft + folders.getWidth(); foldersY = getY(folders); foldersTypeface = folders.getTypeface(); foldersFontSize = folders.getTextSize(); } else { foldersLeft = 0; foldersRight = 0; foldersY = 0; foldersTypeface = null; foldersFontSize = 0; } final View colorBlock = view.findViewById(R.id.color_block); if (config.isColorBlockVisible() && colorBlock != null) { colorBlockX = getX(colorBlock); colorBlockY = getY(colorBlock); colorBlockWidth = colorBlock.getWidth(); colorBlockHeight = colorBlock.getHeight(); } else { colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0; } if (config.isReplyStateVisible()) { replyStateX = getX(replyState); replyStateY = getY(replyState); } else { replyStateX = replyStateY = 0; } if (config.isPersonalIndicatorVisible()) { personalIndicatorX = getX(personalIndicator); personalIndicatorY = getY(personalIndicator); } else { personalIndicatorX = personalIndicatorY = 0; } final View infoIcon = view.findViewById(R.id.info_icon); infoIconX = getX(infoIcon); infoIconXRight = infoIconX + infoIcon.getWidth(); infoIconY = getY(infoIcon); final TextView date = (TextView) view.findViewById(R.id.date); dateX = getX(date); dateXRight = dateX + date.getWidth(); dateY = getY(date); datePaddingStart = ViewUtils.getPaddingStart(date); dateFontSize = date.getTextSize(); dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline(); final View paperclip = view.findViewById(R.id.paperclip); paperclipY = getY(paperclip); paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip); height = view.getHeight() + sendersTopAdjust; Utils.traceEndSection(); }