当前位置: 首页>>代码示例>>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;未经允许,请勿转载。