List of usage examples for android.widget TextView setTextScaleX
@android.view.RemotableViewMethod public void setTextScaleX(float size)
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public void layoutImportantNotice(final View importantNoticeStrip, final String importantNoticeTitle) { final TextView titleView = (TextView) importantNoticeStrip.findViewById(R.id.important_notice_title); final int width = titleView.getWidth() - titleView.getPaddingLeft() - titleView.getPaddingRight(); titleView.setTextColor(mColorAutoCorrect); titleView.setText(importantNoticeTitle); titleView.setTextScaleX(1.0f); // Reset textScaleX. final float titleScaleX = getTextScaleX(importantNoticeTitle, width, titleView.getPaint()); titleView.setTextScaleX(titleScaleX); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) { final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance() .getCurrent().mShouldShowUiToAcceptTypedWord; final int stripWidth = addToDictionaryStrip.getWidth(); final int width = shouldShowUiToAcceptTypedWord ? stripWidth : stripWidth - mDividerWidth - mPadding * 2; final TextView wordView = (TextView) addToDictionaryStrip.findViewById(R.id.word_to_save); wordView.setTextColor(mColorTypedWord); final int wordWidth = (int) (width * mCenterSuggestionWeight); final CharSequence wordToSave = getEllipsizedText(word, wordWidth, wordView.getPaint()); final float wordScaleX = wordView.getTextScaleX(); wordView.setText(wordToSave);//from ww w.j a v a 2s.c o m wordView.setTextScaleX(wordScaleX); setLayoutWeight(wordView, mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT); final int wordVisibility = shouldShowUiToAcceptTypedWord ? View.GONE : View.VISIBLE; wordView.setVisibility(wordVisibility); addToDictionaryStrip.findViewById(R.id.word_to_save_divider).setVisibility(wordVisibility); final Resources res = addToDictionaryStrip.getResources(); final CharSequence hintText; final int hintWidth; final float hintWeight; final TextView hintView = (TextView) addToDictionaryStrip.findViewById(R.id.hint_add_to_dictionary); if (shouldShowUiToAcceptTypedWord) { hintText = res.getText(R.string.hint_add_to_dictionary_without_word); hintWidth = width; hintWeight = 1.0f; hintView.setGravity(Gravity.CENTER); } else { final boolean isRtlLanguage = (ViewCompat .getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL); final String arrow = isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW; final boolean isRtlSystem = SubtypeLocaleUtils.isRtlLanguage(res.getConfiguration().locale); final CharSequence hint = res.getText(R.string.hint_add_to_dictionary); hintText = (isRtlLanguage == isRtlSystem) ? (arrow + hint) : (hint + arrow); hintWidth = width - wordWidth; hintWeight = 1.0f - mCenterSuggestionWeight; hintView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); } hintView.setTextColor(mColorAutoCorrect); final float hintScaleX = getTextScaleX(hintText, hintWidth, hintView.getPaint()); hintView.setText(hintText); hintView.setTextScaleX(hintScaleX); setLayoutWeight(hintView, hintWeight, ViewGroup.LayoutParams.MATCH_PARENT); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
private int layoutPunctuationsAndReturnStartIndexOfMoreSuggestions( final PunctuationSuggestions punctuationSuggestions, final ViewGroup stripView) { final int countInStrip = Math.min(punctuationSuggestions.size(), PUNCTUATIONS_IN_STRIP); for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) { if (positionInStrip != 0) { // Add divider if this isn't the left most suggestion in suggestions strip. addDivider(stripView, mDividerViews.get(positionInStrip)); }/* ww w.j av a 2 s . c o m*/ final TextView wordView = mWordViews.get(positionInStrip); final String punctuation = punctuationSuggestions.getLabel(positionInStrip); // {@link TextView#getTag()} is used to get the index in suggestedWords at // {@link SuggestionStripView#onClick(View)}. wordView.setTag(positionInStrip); wordView.setText(punctuation); wordView.setContentDescription(punctuation); wordView.setTextScaleX(1.0f); wordView.setCompoundDrawables(null, null, null, null); wordView.setTextColor(mColorAutoCorrect); stripView.addView(wordView); setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight); } mMoreSuggestionsAvailable = (punctuationSuggestions.size() > countInStrip); return countInStrip; }
From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java
private void setTextViewStyle(View v) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); // TODO/*w w w .j a v a 2 s . co m*/ //tab.setTextColor(tabTextColor); ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, //1 new int[] { android.R.attr.state_selected }, //2 new int[] {} //3 }, new int[] { Color.WHITE, //1 Color.WHITE, //2 getResources().getColor(R.color.tab_text_color_unselected) //3 }); tab.setTextColor(colorStateList); tab.setTextScaleX(tabTextScaleX); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
/** * Format appropriately the suggested word in {@link #mWordViews} specified by * <code>positionInStrip</code>. When the suggested word doesn't exist, the corresponding * {@link TextView} will be disabled and never respond to user interaction. The suggested word * may be shrunk or ellipsized to fit in the specified width. * * The <code>positionInStrip</code> argument is the index in the suggestion strip. The indices * increase towards the right for LTR scripts and the left for RTL scripts, starting with 0. * The position of the most important suggestion is in {@link #mCenterPositionInStrip}. This * usually doesn't match the index in <code>suggedtedWords</code> -- see * {@link #getPositionInSuggestionStrip(int,SuggestedWords)}. * * @param positionInStrip the position in the suggestion strip. * @param width the maximum width for layout in pixels. * @return the {@link TextView} containing the suggested word appropriately formatted. *///from w w w .j av a2 s .co m private TextView layoutWord(final int positionInStrip, final int width) { final TextView wordView = mWordViews.get(positionInStrip); final CharSequence word = wordView.getText(); if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) { // TODO: This "more suggestions hint" should have a nicely designed icon. wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, mMoreSuggestionsHint); // HACK: Align with other TextViews that have no compound drawables. wordView.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight()); } else { wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack. // Use a simple {@link String} to avoid the issue. wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString()); final CharSequence text = getEllipsizedText(word, width, wordView.getPaint()); final float scaleX = getTextScaleX(word, width, wordView.getPaint()); wordView.setText(text); // TextView.setText() resets text scale x to 1.0. wordView.setTextScaleX(Math.max(scaleX, MIN_TEXT_XSCALE)); // A <code>wordView</code> should be disabled when <code>word</code> is empty in order to // make it unclickable. // With accessibility touch exploration on, <code>wordView</code> should be enabled even // when it is empty to avoid announcing as "disabled". wordView.setEnabled( !TextUtils.isEmpty(word) || AccessibilityUtils.getInstance().isTouchExplorationEnabled()); return wordView; }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripLayoutHelper.java
/** * Format appropriately the suggested word in {@link #mWordViews} specified by * <code>positionInStrip</code>. When the suggested word doesn't exist, the corresponding * {@link TextView} will be disabled and never respond to user interaction. The suggested word * may be shrunk or ellipsized to fit in the specified width. * * The <code>positionInStrip</code> argument is the index in the suggestion strip. The indices * increase towards the right for LTR scripts and the left for RTL scripts, starting with 0. * The position of the most important suggestion is in {@link #mCenterPositionInStrip}. This * usually doesn't match the index in <code>suggedtedWords</code> -- see * {@link #getPositionInSuggestionStrip(int,SuggestedWords)}. * * @param positionInStrip the position in the suggestion strip. * @param width the maximum width for layout in pixels. * @return the {@link TextView} containing the suggested word appropriately formatted. *//*from w ww. j a va 2s . c o m*/ private TextView layoutWord(final int positionInStrip, final int width) { // final TextView wordView = mWordViews.get(positionInStrip); final TextView wordView = mWordViews.get(positionInStrip); final CharSequence word = wordView.getText(); if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) { // TODO: This "more suggestions hint" should have a nicely designed icon. wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, mMoreSuggestionsHint); // HACK: Align with other TextViews that have no compound drawables. wordView.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight()); } else { wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack. // Use a simple {@link String} to avoid the issue. wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString()); final CharSequence text = getEllipsizedText(word, width, wordView.getPaint()); final float scaleX = getTextScaleX(word, width, wordView.getPaint()); wordView.setText(text); // TextView.setText() resets text scale x to 1.0. wordView.setTextScaleX(Math.max(scaleX, MIN_TEXT_XSCALE)); // A <code>wordView</code> should be disabled when <code>word</code> is empty in order to // make it unclickable. // With accessibility touch exploration on, <code>wordView</code> should be enabled even // when it is empty to avoid announcing as "disabled". wordView.setEnabled( !TextUtils.isEmpty(word) || AccessibilityUtils.getInstance().isTouchExplorationEnabled()); return wordView; }