當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。