当前位置: 首页>>代码示例>>Java>>正文


Java TextView.setTextScaleX方法代码示例

本文整理汇总了Java中android.widget.TextView.setTextScaleX方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setTextScaleX方法的具体用法?Java TextView.setTextScaleX怎么用?Java TextView.setTextScaleX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setTextScaleX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layoutPunctuationsAndReturnStartIndexOfMoreSuggestions

import android.widget.TextView; //导入方法依赖的package包/类
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));
        }

        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;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:26,代码来源:SuggestionStripLayoutHelper.java

示例2: layoutWord

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 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.
 */
private TextView layoutWord(final Context context, 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)
                ? context.getResources().getString(R.string.spoken_empty_suggestion)
                : word.toString());
    final CharSequence text = getEllipsizedTextWithSettingScaleX(
            word, width, wordView.getPaint());
    final float scaleX = wordView.getTextScaleX();
    wordView.setText(text); // TextView.setText() resets text scale x to 1.0.
    wordView.setTextScaleX(scaleX);
    // 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;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:48,代码来源:SuggestionStripLayoutHelper.java

示例3: layoutImportantNotice

import android.widget.TextView; //导入方法依赖的package包/类
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); // TextView.setText() resets text scale x to 1.0.
    final float titleScaleX = getTextScaleX(importantNoticeTitle, width, titleView.getPaint());
    titleView.setTextScaleX(titleScaleX);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:12,代码来源:SuggestionStripLayoutHelper.java


注:本文中的android.widget.TextView.setTextScaleX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。