本文整理匯總了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);
}