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


Java TextViewCompat.setTextAppearance方法代码示例

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


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

示例1: initValueView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private void initValueView() {
    mValueTextView = (TextView) findViewById(R.id.text_value);

    if (mValueTextAppearanceResId != INVALID_RES) {
        TextViewCompat.setTextAppearance(mValueTextView, mValueTextAppearanceResId);
    }

    if (mValueTextColor != 0) {
        mValueTextView.setTextColor(mValueTextColor);
    }

    if (mValueTextSize != INVALID_RES) {
        mValueTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mValueTextSize);
    }

    LinearLayout.LayoutParams layoutParams = (LayoutParams) mValueTextView.getLayoutParams();
    if (mOrientation == HORIZONTAL) {
        layoutParams.setMargins(mValueMarginStart, 0, mValueMarginEnd, 0);
    } else {
        layoutParams.setMargins(0, mValueMarginStart, 0, mValueMarginEnd);
    }

    mValueTextView.setLayoutParams(layoutParams);

    setValue();
}
 
开发者ID:michaelmuenzer,项目名称:ScrollableNumberPicker,代码行数:27,代码来源:ScrollableNumberPicker.java

示例2: updateCounter

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
void updateCounter(int length) {
  boolean wasCounterOverflowed = mCounterOverflowed;
  if (mCounterMaxLength == INVALID_MAX_LENGTH) {
    mCounterView.setText(String.valueOf(length));
    mCounterOverflowed = false;
  } else {
    mCounterOverflowed = length > mCounterMaxLength;
    if (wasCounterOverflowed != mCounterOverflowed) {
              TextViewCompat.setTextAppearance(mCounterView, mCounterOverflowed
                      ? mCounterOverflowTextAppearance : mCounterTextAppearance);
    }
          mCounterView.setText(getContext().getString(R.string.character_counter_pattern,
                  length, mCounterMaxLength));
  }
  if (mEditText != null && wasCounterOverflowed != mCounterOverflowed) {
    updateLabelState(false);
    updateEditTextBackground();
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:20,代码来源:TextInputLayout.java

示例3: RecyclerViewScrollbar

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public RecyclerViewScrollbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RecyclerViewScrollbar, defStyleAttr, 0);
    mRecyclerViewId = ta.getResourceId(R.styleable.RecyclerViewScrollbar_recyclerView, 0);
    mScrollbarDrawable = ta.getDrawable(R.styleable.RecyclerViewScrollbar_scrollbarDrawable);
    mLetterDrawable = ta.getDrawable(R.styleable.RecyclerViewScrollbar_letterDrawable);
    int letterTextResId = ta.getResourceId(R.styleable.RecyclerViewScrollbar_letterTextAppearance, 0);
    mMinScrollbarHeight = ta.getDimensionPixelOffset(R.styleable.RecyclerViewScrollbar_minScrollbarHeight, 0);
    ta.recycle();

    mLetterView = new TextView(getContext());
    mLetterView.setBackgroundDrawable(mLetterDrawable);
    TextViewCompat.setTextAppearance(mLetterView, letterTextResId);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = GravityCompat.END;
    mLetterView.setLayoutParams(params);
    mLetterView.setGravity(Gravity.CENTER);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:21,代码来源:RecyclerViewScrollbar.java

示例4: setDateTextAppearance

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
/**
 * 设置日期天数字体样式
 *
 * @param isSelected
 */
public void setDateTextAppearance(boolean isSelected) {
    if (isSelected) {
        if (itemStyle != null && itemStyle.getDateTextCheckedAppearance() > 0) {
            TextViewCompat.setTextAppearance(dayText, itemStyle.getDateTextCheckedAppearance());
        } else {
            TextViewCompat.setTextAppearance(dayText, R.style.SelectedDayViewStyle);
        }
    } else {
        if (itemStyle != null && itemStyle.getDateTextAppearance() > 0) {
            TextViewCompat.setTextAppearance(dayText, itemStyle.getDateTextAppearance());
        } else {
            TextViewCompat.setTextAppearance(dayText, R.style.DefaultDayViewStyle);
        }
    }
}
 
开发者ID:JieJacket,项目名称:CustomWidget,代码行数:21,代码来源:DayView.java

示例5: createTitle

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private TextView createTitle(SwipeMenuItem item) {
    TextView textView = new TextView(getContext());
    textView.setText(item.getText());
    textView.setGravity(Gravity.CENTER);
    int textSize = item.getTextSize();
    if (textSize > 0)
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    ColorStateList textColor = item.getTitleColor();
    if (textColor != null)
        textView.setTextColor(textColor);
    int textAppearance = item.getTextAppearance();
    if (textAppearance != 0)
        TextViewCompat.setTextAppearance(textView, textAppearance);
    Typeface typeface = item.getTextTypeface();
    if (typeface != null)
        textView.setTypeface(typeface);
    return textView;
}
 
开发者ID:yanzhenjie,项目名称:SwipeRecyclerView,代码行数:19,代码来源:SwipeMenuView.java

示例6: createDummyTextView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@SuppressLint("PrivateResource")
private void createDummyTextView(Context context) {
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), null,
            R.styleable.Toolbar, R.attr.toolbarStyle, 0);
    int titleTextAppearance =
            a.getResourceId(R.styleable.Toolbar_titleTextAppearance, 0);
    a.recycle();

    dummy = new TextView(context);
    dummy.setSingleLine();
    dummy.setEllipsize(TextUtils.TruncateAt.END);
    TextViewCompat.setTextAppearance(dummy, titleTextAppearance);
    collapsedTextSize = dummy.getTextSize();
    expendedTextSize = collapsedTextSize * TEXT_SCALE_FACTOR;
    dummy.setTextSize(ViewUtils.convertPixelToSp(expendedTextSize));
    dummy.setVisibility(INVISIBLE);
    addView(dummy, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
 
开发者ID:wix,项目名称:react-native-navigation,代码行数:19,代码来源:CollapsingTextView.java

示例7: setData

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public void setData(Collection<Row> rows) {
    gridLayout.removeViews(1, gridLayout.getChildCount() - 1);
    for (Row row : rows) {
        {
            TextView nameView = new TextView(getContext());
            TextViewCompat.setTextAppearance(nameView, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Body1);
            nameView.setText(row.name());
            GridLayout.LayoutParams params = new GridLayout.LayoutParams();
            params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
            gridLayout.addView(nameView, params);
        }
        {
            TextView valueView = new TextView(getContext());
            TextViewCompat.setTextAppearance(valueView, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Body1);
            valueView.setText(row.value());
            gridLayout.addView(valueView);
        }
    }
}
 
开发者ID:evant,项目名称:PokeMVVM,代码行数:20,代码来源:TableCardLayout.java

示例8: updateCounter

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
void updateCounter(int length) {
    boolean wasCounterOverflowed = counterOverflowed;
    if (counterMaxLength == INVALID_MAX_LENGTH) {
        counterView.setText(String.valueOf(length));
        counterOverflowed = false;
    } else {
        counterOverflowed = length > counterMaxLength;
        if (wasCounterOverflowed != counterOverflowed) {
            TextViewCompat.setTextAppearance(counterView, counterOverflowed ?
                    counterOverflowTextAppearance : counterTextAppearance);
        }
        setCounterText(length);
    }
    if (editText != null && wasCounterOverflowed != counterOverflowed) {
        updateLabelState(false);
        updateEditTextBackground();
    }
}
 
开发者ID:bufferapp,项目名称:BufferTextInputLayout,代码行数:19,代码来源:BufferTextInputLayout.java

示例9: updateViewHolderAppearance

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private void updateViewHolderAppearance(@NonNull LightningViewHolder viewHolder, boolean isForeground) {
    if (isForeground) {
        Drawable foregroundDrawable = null;
        if (!mDrawerTabs) {
            foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap);
            if (!mIsIncognito && mColorMode) {
                foregroundDrawable.setColorFilter(mUiController.getUiColor(), PorterDuff.Mode.SRC_IN);
            }
        }
        TextViewCompat.setTextAppearance(viewHolder.txtTitle, R.style.boldText);
        if (!mDrawerTabs) {
            DrawableUtils.setBackground(viewHolder.layout, foregroundDrawable);
        }
    } else {
        TextViewCompat.setTextAppearance(viewHolder.txtTitle, R.style.normalText);
        if (!mDrawerTabs) {
            DrawableUtils.setBackground(viewHolder.layout, mBackgroundTabDrawable);
        }
    }
}
 
开发者ID:JTechMe,项目名称:JumpGo,代码行数:21,代码来源:TabsFragment.java

示例10: setTextAppearanceCompatWithErrorFallback

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
void setTextAppearanceCompatWithErrorFallback(TextView textView, @StyleRes int textAppearance) {
  boolean useDefaultColor = false;
  try {
    TextViewCompat.setTextAppearance(textView, textAppearance);

    if (VERSION.SDK_INT >= VERSION_CODES.M
        && textView.getTextColors().getDefaultColor() == Color.MAGENTA) {
      // Caused by our theme not extending from Theme.Design*. On API 23 and
      // above, unresolved theme attrs result in MAGENTA rather than an exception.
      // Flag so that we use a decent default
      useDefaultColor = true;
    }
  } catch (Exception e) {
    // Caused by our theme not extending from Theme.Design*. Flag so that we use
    // a decent default
    useDefaultColor = true;
  }
  if (useDefaultColor) {
    // Probably caused by our theme not extending from Theme.Design*. Instead
    // we manually set something appropriate
    TextViewCompat.setTextAppearance(textView, R.style.TextAppearance_AppCompat_Caption);
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.error_color_material));
  }
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:25,代码来源:TextInputLayout.java

示例11: updateCounter

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
void updateCounter(int length) {
  boolean wasCounterOverflowed = mCounterOverflowed;
  if (mCounterMaxLength == INVALID_MAX_LENGTH) {
    mCounterView.setText(String.valueOf(length));
    mCounterOverflowed = false;
  } else {
    mCounterOverflowed = length > mCounterMaxLength;
    if (wasCounterOverflowed != mCounterOverflowed) {
      TextViewCompat.setTextAppearance(
          mCounterView,
          mCounterOverflowed ? mCounterOverflowTextAppearance : mCounterTextAppearance);
    }
    mCounterView.setText(
        getContext().getString(R.string.character_counter_pattern, length, mCounterMaxLength));
  }
  if (mEditText != null && wasCounterOverflowed != mCounterOverflowed) {
    updateLabelState(false);
    updateEditTextBackground();
  }
}
 
开发者ID:google,项目名称:iosched,代码行数:21,代码来源:TextInputLayout.java

示例12: setErrorTextAppearance

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
/**
   * Sets the text color and size for the error message from the specified
   * TextAppearance resource.
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_errorTextAppearance
 */
public void setErrorTextAppearance(@StyleRes int resId) {
  mErrorTextAppearance = resId;
  if (mErrorView != null) {
    TextViewCompat.setTextAppearance(mErrorView, resId);
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:13,代码来源:TextInputLayout.java

示例13: setCounterEnabled

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
/**
 * Whether the character counter functionality is enabled or not in this layout.
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_counterEnabled
 */
public void setCounterEnabled(boolean enabled) {
  if (mCounterEnabled != enabled) {
    if (enabled) {
      mCounterView = new TextView(getContext());
      mCounterView.setId(R.id.textinput_counter);
      if (mTypeface != null) {
        mCounterView.setTypeface(mTypeface);
      }
      mCounterView.setMaxLines(1);
      try {
        TextViewCompat.setTextAppearance(mCounterView, mCounterTextAppearance);
      } catch (Exception e) {
        // Probably caused by our theme not extending from Theme.Design*. Instead
        // we manually set something appropriate
        TextViewCompat.setTextAppearance(
            mCounterView, android.R.style.TextAppearance_Material_Caption);
        mCounterView.setTextColor(
            ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
      }
      addIndicator(mCounterView, -1);
      if (mEditText == null) {
        updateCounter(0);
      } else {
        updateCounter(mEditText.getText().length());
      }
    } else {
      removeIndicator(mCounterView);
      mCounterView = null;
    }
    mCounterEnabled = enabled;
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:38,代码来源:TextInputLayout.java

示例14: addDayView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private void addDayView(Context context) {

        dayText = new TextView(context);
        LayoutParams dayParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dayParams.gravity = Gravity.CENTER_HORIZONTAL;
        dayText.setLayoutParams(dayParams);
        dayText.setGravity(Gravity.CENTER);
        TextViewCompat.setTextAppearance(dayText, R.style.DefaultDayViewStyle);
        dayText.setBackgroundResource(R.drawable.day_view_content_background);
        dayText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        dayParams.bottomMargin = ViewUtils.dp2px(context, 2);
        addView(dayText);
    }
 
开发者ID:JieJacket,项目名称:CustomWidget,代码行数:14,代码来源:DayView.java

示例15: setChannelNameAppearance

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
/**
 * To set a channel name TextView style via res id.
 *
 * @param resId a style res id which to style channel name TextView.
 */
public void setChannelNameAppearance(@StyleRes int resId) {
    if (mChannelNameTextView == null) {
        Log.e(TAG, "channel name text view is null.");
        return;
    }

    TextViewCompat.setTextAppearance(mChannelNameTextView, resId);
}
 
开发者ID:StraaS,项目名称:StraaS-android-sdk-sample,代码行数:14,代码来源:StraasPlayerView.java


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