當前位置: 首頁>>代碼示例>>Java>>正文


Java View.setBackgroundDrawable方法代碼示例

本文整理匯總了Java中android.view.View.setBackgroundDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setBackgroundDrawable方法的具體用法?Java View.setBackgroundDrawable怎麽用?Java View.setBackgroundDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.setBackgroundDrawable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCircleButtonStateListDrawable

import android.view.View; //導入方法依賴的package包/類
public void setCircleButtonStateListDrawable(View circleButton, int radius,int color) {
    WeakReference<Bitmap> imageNormal = new WeakReference<>(Bitmap.createBitmap(2 * radius, 2 * radius, Bitmap.Config.ARGB_8888));
    Canvas canvasNormal = new Canvas(imageNormal.get());
    Paint paintNormal = new Paint();
    paintNormal.setAntiAlias(true);
    paintNormal.setColor(color);
    canvasNormal.drawCircle(radius, radius, radius, paintNormal);
    StateListDrawable stateListDrawable = new StateListDrawable();
    stateListDrawable.addState(StateSet.WILD_CARD, new BitmapDrawable(circleButton.getContext().getResources(), imageNormal.get()));
    if (android.os.Build.VERSION.SDK_INT >= 16) {
        circleButton.setBackground(stateListDrawable);
    } else {
        circleButton.setBackgroundDrawable(stateListDrawable);
    }

}
 
開發者ID:shenhuanet,項目名稱:OpenEyesReading-android,代碼行數:17,代碼來源:Util.java

示例2: onLayout

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View v = getChildAt(i);

        if (v instanceof NavigationMenuView) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                v.setBackground(settings.getBackgroundDrawable());
            } else {
                v.setBackgroundDrawable(settings.getBackgroundDrawable());
            }
        }
    }
}
 
開發者ID:naseemali925,項目名稱:ShapedNavigationView,代碼行數:17,代碼來源:ShapedNavigationView.java

示例3: apply

import android.view.View; //導入方法依賴的package包/類
@Override
public void apply(View view) {
	
	if(RES_TYPE_NAME_COLOR.equals(attrValueTypeName)){
		view.setBackgroundColor(SkinManager.getInstance().getColor(attrValueRefId));
		Log.i("attr", "_________________________________________________________");
		Log.i("attr", "apply as color");
	}else if(RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)){
		Drawable bg = SkinManager.getInstance().getDrawable(attrValueRefId);
		view.setBackgroundDrawable(bg);
		Log.i("attr", "_________________________________________________________");
		Log.i("attr", "apply as drawable");
		Log.i("attr", "bg.toString()  " + bg.toString());
		
		Log.i("attr", this.attrValueRefName + " 是否可變換狀態? : " + bg.isStateful());
	}
}
 
開發者ID:stven0king,項目名稱:Android-Skin-Loader,代碼行數:18,代碼來源:BackgroundAttr.java

示例4: blur

import android.view.View; //導入方法依賴的package包/類
public static void blur(Context context, Bitmap bkg, View view) {
    long startMs = System.currentTimeMillis();
    float radius = 15;
    float scaleFactor = 8;
    //放大到整個view的大小
    bkg = DrawableProvider.getReSizeBitmap(bkg, view.getMeasuredWidth(), view.getMeasuredHeight());

    Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth() / scaleFactor)
            , (int) (view.getMeasuredHeight() / scaleFactor), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.translate(-view.getLeft() / scaleFactor, -view.getTop() / scaleFactor);
    canvas.scale(1 / scaleFactor, 1 / scaleFactor);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bkg, 0, 0, paint);
    overlay = FastBlur.doBlur(overlay, (int) radius, true);
    view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay));
    Log.w("test", "cost " + (System.currentTimeMillis() - startMs) + "ms");
}
 
開發者ID:yangxp108,項目名稱:MVPArms_Fragment-fragment,代碼行數:20,代碼來源:FastBlur.java

示例5: setBackground

import android.view.View; //導入方法依賴的package包/類
public static void setBackground(View view, Drawable drawable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(drawable);
    } else {
        view.setBackgroundDrawable(drawable);
    }
}
 
開發者ID:huangjingqiang,項目名稱:SWDemo,代碼行數:8,代碼來源:ViewUtil.java

示例6: addToAttachLayout

import android.view.View; //導入方法依賴的package包/類
public void addToAttachLayout(View view) {
    if (attachButton == null) {
        return;
    }
    if (view.getParent() != null) {
        ViewGroup viewGroup = (ViewGroup) view.getParent();
        viewGroup.removeView(view);
    }
    if (Build.VERSION.SDK_INT >= 21) {
        view.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR));
    }
    attachButton.addView(view, LayoutHelper.createLinear(48, 48));
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:14,代碼來源:ChatActivityEnterView.java

示例7: setBackGround

import android.view.View; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static void setBackGround(View view, Drawable drawable){
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN){
    view.setBackgroundDrawable(drawable);
  }
  else{
    view.setBackground(drawable);
  }
}
 
開發者ID:erguotou520,項目名稱:weex-uikit,代碼行數:10,代碼來源:WXViewUtils.java

示例8: setBackground

import android.view.View; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
   @SuppressWarnings("deprecation")
public static void setBackground(View view, Drawable drawable){
	if(Utils.hasJellyBean()){
		view.setBackground(drawable);
	}
	else{
		view.setBackgroundDrawable(drawable);
	}
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:11,代碼來源:ViewCompat.java

示例9: setBackground

import android.view.View; //導入方法依賴的package包/類
public static void setBackground(View v, Drawable drawable) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		v.setBackground(drawable);
	} else {
		v.setBackgroundDrawable(drawable);
	}
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:8,代碼來源:Helper.java

示例10: setBackground

import android.view.View; //導入方法依賴的package包/類
public static void setBackground(View view, Drawable background) {
	if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
		SDK16.setBackground(view, background);
	} else {
		view.setBackgroundDrawable(background);
	}
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:8,代碼來源:ViewCompat.java

示例11: setImageToView

import android.view.View; //導入方法依賴的package包/類
private static void setImageToView(View toView, Bitmap bitmap) {
    if (toView instanceof ImageView) {
        final ImageView toImageView = (ImageView) toView;
        toImageView.setImageBitmap(bitmap);
    } else {
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            toView.setBackground(new BitmapDrawable(toView.getResources(), bitmap));
        } else {
            toView.setBackgroundDrawable(new BitmapDrawable(toView.getResources(), bitmap));
        }
    }
}
 
開發者ID:MSay2,項目名稱:Mire,代碼行數:13,代碼來源:TransitionAnimation.java

示例12: setupFooterView

import android.view.View; //導入方法依賴的package包/類
private void setupFooterView(int lastRowHeight) {

        // closes #12, add footer for plain style tables in order to make the
        // effect of repeating
        // rows across table height.
        if (mStyle == ATableViewStyle.Plain) {
            final View footerView = new FrameLayout(getContext());

            // add listener to resize after layout has been completed.
            getViewTreeObserver().addOnGlobalLayoutListener(
                    new ViewTreeObserver.OnGlobalLayoutListener() {
                        public void onGlobalLayout() {
                            getViewTreeObserver().removeGlobalOnLayoutListener(
                                    this);

                            int footerHeight = getHeight()
                                    - getInternalAdapter().getContentHeight();
                            AbsListView.LayoutParams params = new AbsListView.LayoutParams(
                                    AbsListView.LayoutParams.MATCH_PARENT,
                                    footerHeight > 0 ? footerHeight : 0);
                            footerView.setLayoutParams(params);
                        }
                    });
            int sdk = android.os.Build.VERSION.SDK_INT;
            if (sdk > android.os.Build.VERSION_CODES.JELLY_BEAN) {
                footerView.setBackground(new ATableViewPlainFooterDrawable(
                        this, lastRowHeight));
            } else {
                footerView
                        .setBackgroundDrawable(new ATableViewPlainFooterDrawable(
                                this, lastRowHeight));
            }
            addFooterView(footerView);
        }
    }
 
開發者ID:hh-in-zhuzhou,項目名稱:ShangHanLun,代碼行數:36,代碼來源:ATableView.java

示例13: updateTabStyles

import android.view.View; //導入方法依賴的package包/類
private void updateTabStyles() {

		for (int i = 0; i < tabCount; i++) {

			View v = tabsContainer.getChildAt(i);
			if (tabBackgroundResId != -1) {
				//v.setBackgroundResource(tabBackgroundResId);
				v.setBackgroundDrawable(ContextCompat.getDrawable(getContext(),tabBackgroundResId));
			}

			if (v instanceof TextView) {

				TextView tab = (TextView) v;
				tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
				tab.setTypeface(tabTypeface, tabTypefaceStyle);
				if (pager.getCurrentItem() == i) {
					pageSelected=i;
					tab.setTextColor(tabSelectTextColor);
				} else {
					tab.setTextColor(tabUnSelectTextColor);
				}

				// setAllCaps() is only available from API 14, so the upper case
				// is made manually if we are on a
				// pre-ICS-build
				if (textAllCaps) {
					if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
						tab.setAllCaps(true);
					} else {
						tab.setText(tab.getText().toString()
								.toUpperCase(locale));
					}
				}
			}
		}

	}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:38,代碼來源:PagerSlidingTabStrip.java

示例14: setBackground

import android.view.View; //導入方法依賴的package包/類
/**
 * 設置背景
 *
 * @param fragment   fragment
 * @param background 背景
 */
public static void setBackground(@NonNull Fragment fragment, Drawable background) {
    View view = fragment.getView();
    if (view != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.setBackground(background);
        } else {
            view.setBackgroundDrawable(background);
        }
    }
}
 
開發者ID:yangxp108,項目名稱:MVPArms_Fragment-fragment,代碼行數:17,代碼來源:FragmentUtils.java

示例15: tintWidget

import android.view.View; //導入方法依賴的package包/類
public static void tintWidget(View view, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTint(wrappedDrawable.mutate(), color);
    view.setBackgroundDrawable(wrappedDrawable);
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:6,代碼來源:Utils.java


注:本文中的android.view.View.setBackgroundDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。