本文整理汇总了Java中android.support.v4.view.ViewCompat.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.setBackground方法的具体用法?Java ViewCompat.setBackground怎么用?Java ViewCompat.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.setBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSelectedChanged
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,int actionState) {
if (actionState == OnItemStateChangedListener.ACTION_STATE_DRAG) {
setTitle("状态:拖拽");
// 拖拽的时候背景就透明了,这里我们可以添加一个特殊背景。
viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(getBaseContext(),
R.color.white_pressed));
} else if (actionState == OnItemStateChangedListener.ACTION_STATE_SWIPE) {
setTitle("状态:滑动删除");
} else if (actionState == OnItemStateChangedListener.ACTION_STATE_IDLE) {
setTitle("状态:手指松开");
// 在手松开的时候还原背景。
ViewCompat.setBackground(viewHolder.itemView,
ContextCompat.getDrawable(getBaseContext(),
R.drawable.select_white));
}
}
示例2: getView
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected View getView(int position, View convertView, ViewGroup parent) {
EmojiconTextView emojiconTextView;
if (convertView == null || !(convertView instanceof EmojiconTextView)) {
emojiconTextView = new EmojiconTextView(getContext());
emojiconTextView.setTextSize(14);
int padding = QMUIDisplayHelper.dp2px(getContext(), 16);
ViewCompat.setBackground(emojiconTextView, QMUIResHelper.getAttrDrawable(
getContext(), R.attr.qmui_s_list_item_bg_with_border_bottom));
emojiconTextView.setPadding(padding, padding, padding, padding);
emojiconTextView.setMaxLines(8);
emojiconTextView.setTextColor(Color.BLACK);
emojiconTextView.setMovementMethodDefault();
convertView = emojiconTextView;
} else {
emojiconTextView = (EmojiconTextView) convertView;
}
emojiconTextView.setText(getItem(position));
return convertView;
}
示例3: getView
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected View getView(int position, View convertView, ViewGroup parent) {
QMUIQQFaceView qmuiqqFaceView;
if (convertView == null || !(convertView instanceof QMUIQQFaceView)) {
qmuiqqFaceView = new QMUIQQFaceView(getContext());
qmuiqqFaceView.setCompiler(QMUIQQFaceCompiler.getInstance(
QDQQFaceManager.getInstance()));
int padding = QMUIDisplayHelper.dp2px(getContext(), 16);
ViewCompat.setBackground(qmuiqqFaceView, QMUIResHelper.getAttrDrawable(
getContext(), R.attr.qmui_s_list_item_bg_with_border_bottom));
qmuiqqFaceView.setPadding(padding, padding, padding, padding);
qmuiqqFaceView.setLineSpace(QMUIDisplayHelper.dp2px(getContext(), 10));
qmuiqqFaceView.setTextColor(Color.BLACK);
qmuiqqFaceView.setMaxLine(8);
convertView = qmuiqqFaceView;
} else {
qmuiqqFaceView = (QMUIQQFaceView) convertView;
}
qmuiqqFaceView.setText(getItem(position));
return convertView;
}
示例4: TabView
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public TabView(Context context) {
super(context);
if (mTabBackgroundResId != 0) {
/*
ViewCompat.setBackground(
this, AppCompatResources.getDrawable(context, mTabBackgroundResId));
*/
ViewCompat.setBackground(
this, context.getDrawable(mTabBackgroundResId));
}
ViewCompat.setPaddingRelative(this, mTabPaddingStart, mTabPaddingTop,
mTabPaddingEnd, mTabPaddingBottom);
setGravity(Gravity.CENTER);
setOrientation(VERTICAL);
setClickable(true);
ViewCompat.setPointerIcon(this,
PointerIconCompat.getSystemIcon(getContext(), PointerIconCompat.TYPE_HAND));
}
示例5: configureLayoutElevation
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void configureLayoutElevation() {
// 1. Take elevation from header item layout (most important)
mElevation = ViewCompat.getElevation(mStickyHeaderViewHolder.getContentView());
if (mElevation == 0f) {
// 2. Take elevation settings
mElevation = mAdapter.getStickyHeaderElevation();
}
if (mElevation > 0) {
// Needed to elevate the view
ViewCompat.setBackground(mStickyHolderLayout, mStickyHeaderViewHolder.getContentView().getBackground());
}
}
示例6: collapseConfiguration
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
void collapseConfiguration() {
configurationToggleButton.setTag(COLLAPSED);
configurationToggleButton.setText("Configurations");
configurationToggleButton.setTextColor(Color.WHITE);
ViewCompat.setBackground(configurationToggleButton, ContextCompat.getDrawable(getContext(), R.drawable.footer_button_drawable));
configurationContainer.setVisibility(GONE);
}
示例7: expandConfiguration
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
void expandConfiguration() {
configurationToggleButton.setTag(EXPANDED);
configurationToggleButton.setText("Close");
configurationToggleButton.setTextColor(ContextCompat.getColor(getContext(), R.color.close_button_text_color));
ViewCompat.setBackground(configurationToggleButton, ContextCompat.getDrawable(getContext(), R.drawable.footer_button_disabled_drawable));
configurationContainer.setVisibility(VISIBLE);
}
示例8: ViewHolder
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
ViewHolder(@NonNull View view) {
ButterKnife.bind(this, view);
int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
ViewCompat.setBackground(counter, DrawableHelper.getTintedDrawable(
mContext, R.drawable.ic_toolbar_circle, color));
counter.setTextColor(ColorHelper.getTitleTextColor(color));
}
示例9: applyStyle
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public final void applyStyle(MessagesListStyle style) {
super.applyStyle(style);
if (time != null) {
time.setTextColor(style.getOutcomingImageTimeTextColor());
time.setTextSize(TypedValue.COMPLEX_UNIT_PX, style.getOutcomingImageTimeTextSize());
time.setTypeface(time.getTypeface(), style.getOutcomingImageTimeTextStyle());
}
if (imageOverlay != null) {
ViewCompat.setBackground(imageOverlay, style.getOutcomingImageOverlayDrawable());
}
}
示例10: setItemBackground
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void setItemBackground(int background) {
Drawable backgroundDrawable = background == 0
? null : ContextCompat.getDrawable(getContext(), background);
ViewCompat.setBackground(this, backgroundDrawable);
}
示例11: setBackgroundCompat
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Invokes {@link ViewCompat#setBackground(View, Drawable)} with the same arguments.
*/
protected final void setBackgroundCompat(@NonNull final View view, @Nullable final Drawable drawable) {
ViewCompat.setBackground(view, drawable);
}
示例12: setBackgroundCompat
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Invokes {@link ViewCompat#setBackground(android.view.View, Drawable)} with the same arguments.
*/
public final void setBackgroundCompat(@Nullable final Drawable drawable) {
ViewCompat.setBackground(this, drawable);
}
示例13: setBackgroundCompat
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Invokes {@link ViewCompat#setBackground(View, Drawable)} with the same arguments.
*/
public final void setBackgroundCompat(@Nullable final Drawable drawable) {
ViewCompat.setBackground(this, drawable);
}
示例14: setBgDrawable
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static void setBgDrawable(View view, Drawable drawable) {
ViewCompat.setBackground(view, drawable);
}
示例15: setSelectedBackgroundColor
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void setSelectedBackgroundColor(int color) {
GradientDrawable previewBackground = (GradientDrawable) selectedBackgroundColorView.getBackground();
previewBackground.setColor(color);
ViewCompat.setBackground(selectedBackgroundColorView, previewBackground);
}