本文整理汇总了Java中android.support.v4.widget.TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds方法的典型用法代码示例。如果您正苦于以下问题:Java TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds方法的具体用法?Java TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds怎么用?Java TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.widget.TextViewCompat
的用法示例。
在下文中一共展示了TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds方法的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);
}
});
}
示例2: 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);
}
}
示例3: bindView
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder holder = (ViewHolder) view.getTag();
Event event = DatabaseManager.toEvent(cursor, holder.event);
holder.event = event;
holder.time.setText(timeDateFormat.format(event.getStartTime()));
if ((currentTime != -1L) && event.isRunningAtTime(currentTime)) {
// Contrast colors for running event
holder.time.setBackgroundColor(timeRunningBackgroundColor);
holder.time.setTextColor(timeRunningForegroundColor);
} else {
// Normal colors
holder.time.setBackgroundColor(timeBackgroundColor);
holder.time.setTextColor(timeForegroundColor);
}
holder.title.setText(event.getTitle());
int bookmarkDrawable = DatabaseManager.toBookmarkStatus(cursor) ? R.drawable.ic_bookmark_grey600_24dp : 0;
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(holder.title, 0, 0, bookmarkDrawable, 0);
String personsSummary = event.getPersonsSummary();
holder.persons.setText(personsSummary);
holder.persons.setVisibility(TextUtils.isEmpty(personsSummary) ? View.GONE : View.VISIBLE);
holder.room.setText(event.getRoomName());
}
示例4: getView
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_main_menu, parent, false);
convertView.setOnClickListener(sectionClickListener);
}
Section section = getItem(position);
convertView.setSelected(section == currentSection);
TextView tv = (TextView) convertView.findViewById(R.id.section_text);
SpannableString sectionTitle = new SpannableString(getString(section.getTitleResId()));
Drawable sectionIcon = getResources().getDrawable(section.getIconResId());
if (section == currentSection) {
// Special color for the current section
sectionTitle.setSpan(new ForegroundColorSpan(currentSectionForegroundColor), 0, sectionTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// We need to mutate the drawable before applying the ColorFilter, or else all the similar drawable instances will be tinted.
sectionIcon.mutate().setColorFilter(currentSectionForegroundColor, PorterDuff.Mode.SRC_IN);
}
tv.setText(sectionTitle);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(tv, sectionIcon, null, null, null);
return convertView;
}
示例5: bindView
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder holder = (ViewHolder) view.getTag();
Event event = DatabaseManager.toEvent(cursor, holder.event);
holder.event = event;
holder.title.setText(event.getTitle());
int bookmarkDrawable = DatabaseManager.toBookmarkStatus(cursor) ? R.drawable.ic_bookmark_grey600_24dp : 0;
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(holder.title, 0, 0, bookmarkDrawable, 0);
String personsSummary = event.getPersonsSummary();
holder.persons.setText(personsSummary);
holder.persons.setVisibility(TextUtils.isEmpty(personsSummary) ? View.GONE : View.VISIBLE);
holder.trackName.setText(event.getTrack().getName());
Date startTime = event.getStartTime();
Date endTime = event.getEndTime();
String startTimeString = (startTime != null) ? timeDateFormat.format(startTime) : "?";
String endTimeString = (endTime != null) ? timeDateFormat.format(endTime) : "?";
String details;
if (showDay) {
details = String.format("%1$s, %2$s ― %3$s | %4$s", event.getDay().getShortName(), startTimeString, endTimeString, event.getRoomName());
} else {
details = String.format("%1$s ― %2$s | %3$s", startTimeString, endTimeString, event.getRoomName());
}
holder.details.setText(details);
}
示例6: AuthorLayoutViewHolder
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public AuthorLayoutViewHolder(View itemView) {
profileRow = (ViewGroup) itemView;
profileImageView = (ImageView) itemView.findViewById(R.id.profile_image);
authorTextView = (TextView) itemView.findViewById(R.id.discussion_author_text_view);
dateTextView = (TextView) itemView.findViewById(R.id.discussion_date_text_view);
answerTextView = (TextView) itemView.findViewById(R.id.discussion_responses_answer_text_view);
final Context context = answerTextView.getContext();
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
answerTextView,
new IconDrawable(context, FontAwesomeIcons.fa_check_square_o)
.sizeRes(context, R.dimen.edx_base)
.colorRes(context, R.color.edx_success_accent),
null, null, null);
RoboGuice.getInjector(context).injectMembers(this);
}
示例7: createField
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private static TextView createField(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @NonNull final FormField field, @NonNull final String value, boolean readOnly, @NonNull View.OnClickListener onClickListener) {
final TextView textView = (TextView) inflater.inflate(R.layout.edit_user_profile_field, parent, false);
final SpannableString formattedValue = new SpannableString(value);
formattedValue.setSpan(new ForegroundColorSpan(parent.getResources().getColor(R.color.edx_brand_gray_base)), 0, formattedValue.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(ResourceUtil.getFormattedString(parent.getResources(), R.string.edit_user_profile_field, new HashMap<String, CharSequence>() {{
put("label", field.getLabel());
put("value", formattedValue);
}}));
Context context = parent.getContext();
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
textView, null, null, new IconDrawable(context, FontAwesomeIcons.fa_angle_right)
.colorRes(context, R.color.edx_brand_gray_back)
.sizeDp(context, 24), null);
if (readOnly) {
textView.setEnabled(false);
textView.setBackgroundColor(textView.getResources().getColor(R.color.edx_brand_gray_x_back));
} else {
textView.setOnClickListener(onClickListener);
}
parent.addView(textView);
return textView;
}
示例8: getView
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_main_menu, parent, false);
convertView.setOnClickListener(sectionClickListener);
}
Section section = getItem(position);
convertView.setSelected(section == currentSection);
TextView tv = convertView.findViewById(R.id.section_text);
SpannableString sectionTitle = new SpannableString(getString(section.getTitleResId()));
Drawable sectionIcon = AppCompatResources.getDrawable(MainActivity.this, section.getIconResId());
if (section == currentSection) {
// Special color for the current section
sectionTitle.setSpan(new ForegroundColorSpan(currentSectionForegroundColor), 0, sectionTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// We need to mutate the drawable before applying the ColorFilter, or else all the similar drawable instances will be tinted.
sectionIcon.mutate().setColorFilter(currentSectionForegroundColor, PorterDuff.Mode.SRC_IN);
}
tv.setText(sectionTitle);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(tv, sectionIcon, null, null, null);
return convertView;
}
示例9: onBindViewHolder
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, Cursor cursor) {
Context context = holder.itemView.getContext();
Event event = DatabaseManager.toEvent(cursor, holder.event);
holder.event = event;
holder.title.setText(event.getTitle());
boolean isBookmarked = DatabaseManager.toBookmarkStatus(cursor);
Drawable bookmarkDrawable = isBookmarked
? AppCompatResources.getDrawable(context, R.drawable.ic_bookmark_grey600_24dp)
: null;
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(holder.title, null, null, bookmarkDrawable, null);
holder.title.setContentDescription(isBookmarked
? context.getString(R.string.in_bookmarks_content_description, event.getTitle())
: null
);
String personsSummary = event.getPersonsSummary();
holder.persons.setText(personsSummary);
holder.persons.setVisibility(TextUtils.isEmpty(personsSummary) ? View.GONE : View.VISIBLE);
Track track = event.getTrack();
holder.trackName.setText(track.getName());
holder.trackName.setTextColor(ContextCompat.getColor(context, track.getType().getColorResId()));
holder.trackName.setContentDescription(context.getString(R.string.track_content_description, track.getName()));
bindDetails(holder, event);
}
示例10: setItems
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public void setItems(final int[] itemsTextsResIds, final int[] itemsIconsResIds) {
mItemsTextsResIds = itemsTextsResIds;
mItemsIconsResIds = itemsIconsResIds;
if (mItemsTextsResIds != null && mSelectedItemPosition >= 0 && mSelectedItemPosition < mItemsTextsResIds.length)
setText(mItemsTextsResIds[mSelectedItemPosition]);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(this, null, null, isPopupShown() ? mOpenedDrawable : mClosedDrawable, null);
}
示例11: setSelectedItemPosition
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public void setSelectedItemPosition(final int selectedItemPosition) {
int lastSelectedItemPosition = mSelectedItemPosition;
mSelectedItemPosition = selectedItemPosition;
final String itemText = mItemsTextsResIds != null && mSelectedItemPosition >= 0 && mSelectedItemPosition < mItemsTextsResIds.length ?
getResources().getString(mItemsTextsResIds[mSelectedItemPosition]) : null;
setText(itemText);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(FullSizePopupSpinner.this, null, null, mClosedDrawable, null);
if (mOnItemSelectedListener != null)
mOnItemSelectedListener.onItemSelected(FullSizePopupSpinner.this, selectedItemPosition, itemText, lastSelectedItemPosition);
}
示例12: NoVersionsViewHolder
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
NoVersionsViewHolder(View view) {
super(view);
headerView = (TextView) view.findViewById(R.id.information);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_access_time_24dp_grey600, 0, 0, 0);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
explainIncompatibleVersions();
}
});
}
示例13: setDrawables
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private void setDrawables() {
Drawable[] drawables = getDrawables();
if (passwordVisible) {
drawables[2] = shownIcon;
} else {
drawables[2] = hiddenIcon;
}
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(this,
drawables[0], drawables[1], tintDrawable(drawables[2]), drawables[3]);
}
示例14: setCardIcon
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
private void setCardIcon(int icon) {
if (!mDisplayCardIcon || getText().length() == 0) {
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(this, 0, 0, 0, 0);
} else {
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(this, 0, 0, icon, 0);
}
}
示例15: NumberResponsesViewHolder
import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public NumberResponsesViewHolder(View itemView) {
super(itemView);
numberResponsesOrCommentsLabel = (TextView) itemView.
findViewById(R.id.number_responses_or_comments_label);
Context context = numberResponsesOrCommentsLabel.getContext();
Drawable iconDrawable = new IconDrawable(context, FontAwesomeIcons.fa_comment)
.colorRes(context, R.color.edx_brand_gray_base)
.sizeRes(context, R.dimen.edx_small);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
numberResponsesOrCommentsLabel, iconDrawable, null, null, null);
}