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


Java ViewCompat.setBackground方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:leobert-lan,项目名称:UiLib,代码行数:21,代码来源:DragSortSample.java

示例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;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:21,代码来源:QDEmojiconPagerView.java

示例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;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:22,代码来源:QDQQFacePagerView.java

示例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));
    }
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:19,代码来源:TabLayoutLite.java

示例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());
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:StickyHeaderHelper.java

示例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);
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:8,代码来源:SampleFooterView.java

示例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);
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:8,代码来源:SampleFooterView.java

示例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));
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:8,代码来源:FilterAdapter.java

示例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());
    }
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:14,代码来源:MessageHolders.java

示例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);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:6,代码来源:BottomNavigationItemView.java

示例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);
}
 
开发者ID:milosmns,项目名称:silly-android,代码行数:7,代码来源:EasyFragment.java

示例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);
}
 
开发者ID:milosmns,项目名称:silly-android,代码行数:7,代码来源:EasyViewGroup.java

示例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);
}
 
开发者ID:milosmns,项目名称:silly-android,代码行数:7,代码来源:EasyView.java

示例14: setBgDrawable

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static void setBgDrawable(View view, Drawable drawable) {
    ViewCompat.setBackground(view, drawable);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:4,代码来源:ResUtil.java

示例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);
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:6,代码来源:StartActivity.java


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