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