android.widget.TextView#getCompoundPaddingRight ( )源码实例Demo

下面列出了android.widget.TextView#getCompoundPaddingRight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openboard   文件: SuggestionStripLayoutHelper.java
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs,
        final int defStyle, final ArrayList<TextView> wordViews,
        final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) {
    mWordViews = wordViews;
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;

    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(
            R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(
            R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mSuggestionsCountInStrip = a.getInt(
            R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile,
            DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(
            R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size),
            mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(
            R.dimen.config_more_suggestions_row_height);
}
 
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs,
        final int defStyle, final ArrayList<TextView> wordViews,
        final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) {
    mWordViews = wordViews;
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;

    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(
            R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(
            R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mSuggestionsCountInStrip = a.getInt(
            R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile,
            DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(
            R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size),
            mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(
            R.dimen.config_more_suggestions_row_height);
}
 
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs,
        final int defStyle, final ArrayList<TextView> wordViews,
        final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) {
    mWordViews = wordViews;
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;

    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(
            R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(
            R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mSuggestionsCountInStrip = a.getInt(
            R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile,
            DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(
            R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size),
            mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(
            R.dimen.config_more_suggestions_row_height);
}
 
 方法所在类
 同类方法