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


Java TextViewCompat类代码示例

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


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

示例1: addLinkItemView

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
private void addLinkItemView(ViewGroup parent, int resIdText, int resIdDrawable, final String url, String formatArg) {
    TextView view = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.app_details2_link_item, parent, false);
    if (formatArg == null) {
        view.setText(resIdText);
    } else {
        String text = parent.getContext().getString(resIdText, formatArg);
        view.setText(text);
    }
    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(view, resIdDrawable, 0, 0, 0);
    parent.addView(view);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onLinkClicked(url);
        }
    });
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:18,代码来源:AppDetailsRecyclerViewAdapter.java

示例2: 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

示例3: 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

示例4: 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

示例5: onClickCard

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
@Override
public void onClickCard(View v, Update update) {
    // if card is clicked and the line count is bigger than 3 (meaning it can be expanded/"dexpanded")
    TextView tvText = v.findViewById(R.id.tv_updatecard_text);
    View viewExpand = v.findViewById(R.id.view_updatecard_expand);
    if (tvText.getLineCount() > 3) {
        // if current max lines is 3, expand to 100 lines, and else "dexpand" back to 3
        // it uses TextViewCompat instead of the given method for API 15 compatibility
        if (TextViewCompat.getMaxLines(tvText) == 3) {
            tvText.setMaxLines(100);
            viewExpand.setBackgroundResource(R.drawable.ic_arrow_drop_up_grey_600_24dp);
        } else {
            tvText.setMaxLines(3);
            viewExpand.setBackgroundResource(R.drawable.ic_arrow_drop_down_grey_600_24dp);
        }
    }
}
 
开发者ID:kfaryarok,项目名称:kfaryarok-android,代码行数:18,代码来源:MainActivity.java

示例6: 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

示例7: show

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
private static void show(final CharSequence text, final int duration) {
    HANDLER.post(new Runnable() {
        @Override
        public void run() {
            cancel();
            sToast = Toast.makeText(Utils.getApp(), text, duration);
            // solve the font of toast
            TextView tvMessage = sToast.getView().findViewById(android.R.id.message);
            TextViewCompat.setTextAppearance(tvMessage, android.R.style.TextAppearance);
            tvMessage.setTextColor(msgColor);
            sToast.setGravity(gravity, xOffset, yOffset);
            setBg(tvMessage);
            sToast.show();
        }
    });
}
 
开发者ID:Blankj,项目名称:AndroidUtilCode,代码行数:17,代码来源:ToastUtils.java

示例8: 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

示例9: switchMode

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
private void switchMode(boolean isLive) {
    if (mIsLive == isLive) {
        return;
    }
    mIsLive = isLive;

    if (isLive) {
        setContentSeekBarVisibility(GONE);
        setSummaryViewerVisibility(INVISIBLE);

        TextView live = (TextView) View.inflate(mThemeContext, R.layout.live_view, null);
        Drawable drawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_live_player, null);
        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(live, drawable, null, null, null);
        setCustomViewToColumn(live, CUSTOM_COLUMN_BOTTOM_LEFT);
    } else {
        setContentSeekBarVisibility(VISIBLE);
        setSummaryViewerVisibility(VISIBLE);

        removeViewFromCustomColumn(CUSTOM_COLUMN_BOTTOM_LEFT);
    }
}
 
开发者ID:StraaS,项目名称:StraaS-android-sdk-sample,代码行数:22,代码来源:StraasPlayerView.java

示例10: setSelected

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
@Override
public void setSelected(boolean selected) {
    if (selected){
        TextViewCompat.setCompoundDrawablesRelative(
                this,
                null,
                selectDrawable,
                null,
                null
        );
        this.setTextColor(selectColor);
    }else {
        TextViewCompat.setCompoundDrawablesRelative(
                this,
                null,
                normalDrawable,
                null,
                null
        );
        this.setTextColor(normalColor);
    }
    super.setSelected(selected);
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:24,代码来源:SelectTextView.java

示例11: 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

示例12: 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

示例13: testMaintainsStartEndCompoundDrawables

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
@UiThreadTest
@Test
public void testMaintainsStartEndCompoundDrawables() throws Throwable {
  final Activity activity = activityTestRule.getActivity();

  // Set a known set of test compound drawables on the EditText
  final Drawable start = new ColorDrawable(Color.RED);
  final Drawable top = new ColorDrawable(Color.GREEN);
  final Drawable end = new ColorDrawable(Color.BLUE);
  final Drawable bottom = new ColorDrawable(Color.BLACK);

  final TextInputEditText editText = new TextInputEditText(activity);
  TextViewCompat.setCompoundDrawablesRelative(editText, start, top, end, bottom);

  // Now add the EditText to a TextInputLayout
  TextInputLayout til = activity.findViewById(R.id.textinput_noedittext);
  til.addView(editText);

  // Finally assert that all of the drawables are untouched
  final Drawable[] compoundDrawables = TextViewCompat.getCompoundDrawablesRelative(editText);
  assertSame(start, compoundDrawables[0]);
  assertSame(top, compoundDrawables[1]);
  assertSame(end, compoundDrawables[2]);
  assertSame(bottom, compoundDrawables[3]);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:26,代码来源:TextInputLayoutTest.java

示例14: setIcon

import android.support.v4.widget.TextViewCompat; //导入依赖的package包/类
@Override
public void setIcon(Drawable icon) {
  if (icon != null) {
    if (hasIconTintList) {
      Drawable.ConstantState state = icon.getConstantState();
      icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate();
      DrawableCompat.setTintList(icon, iconTintList);
    }
    icon.setBounds(0, 0, iconSize, iconSize);
  } else if (needsEmptyIcon) {
    if (emptyDrawable == null) {
      emptyDrawable =
          ResourcesCompat.getDrawable(
              getResources(), R.drawable.navigation_empty_icon, getContext().getTheme());
      if (emptyDrawable != null) {
        emptyDrawable.setBounds(0, 0, iconSize, iconSize);
      }
    }
    icon = emptyDrawable;
  }
  TextViewCompat.setCompoundDrawablesRelative(textView, icon, null, null, null);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:23,代码来源:NavigationMenuItemView.java

示例15: 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


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