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


Java View.setBackground方法代码示例

本文整理汇总了Java中android.view.View.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java View.setBackground方法的具体用法?Java View.setBackground怎么用?Java View.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addArrowView

import android.view.View; //导入方法依赖的package包/类
/**
 * Adds an arrow view pointing at the original icon.
 * @param horizontalOffset the horizontal offset of the arrow, so that it
 *                              points at the center of the original icon
 */
private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) {
    LinearLayout.LayoutParams layoutParams = new LayoutParams(width, height);
    if (mIsLeftAligned) {
        layoutParams.gravity = Gravity.LEFT;
        layoutParams.leftMargin = horizontalOffset;
    } else {
        layoutParams.gravity = Gravity.RIGHT;
        layoutParams.rightMargin = horizontalOffset;
    }
    if (mIsAboveIcon) {
        layoutParams.topMargin = verticalOffset;
    } else {
        layoutParams.bottomMargin = verticalOffset;
    }

    View arrowView = new View(getContext());
    ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
            width, height, !mIsAboveIcon));
    arrowDrawable.getPaint().setColor(Color.WHITE);
    arrowView.setBackground(arrowDrawable);
    arrowView.setElevation(getElevation());
    addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams);
    return arrowView;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:30,代码来源:DeepShortcutsContainer.java

示例2: setBackgroundActiveColor

import android.view.View; //导入方法依赖的package包/类
public static void setBackgroundActiveColor(View editText, int accentColor) {
    if (editText.getBackground() == null)
        return;
    int normalColor = StyledAttributesHelper.getColor(editText.getContext(),
            R.attr.colorControlNormal, 0);
    int disabledColor = ColorUtils.setAlphaComponent(normalColor, (int) (255.f *
            StyledAttributesHelper.getFloat(editText.getContext(), android.R.attr.disabledAlpha, 1.f)));
    int[][] states = new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{-android.R.attr.state_pressed, -android.R.attr.state_focused},
            new int[]{}
    };
    int[] colors = new int[]{
            disabledColor,
            normalColor,
            accentColor
    };
    ColorStateList list = new ColorStateList(states, colors);
    editText.setBackground(new ColorFilterWorkaroundDrawable(editText.getBackground()));
    ViewCompat.setBackgroundTintList(editText, list);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:22,代码来源:ThemedEditText.java

示例3: onFinishInflate

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    if (mHoldingView == null && mHoldingViewId != NO_ID) {
        mHoldingView = findViewById(mHoldingViewId);
    }

    if (mHoldingView == null) {
        throw new IllegalStateException("Holding view doesn't set. Call setHoldingView before inflate");
    }

    mHoldingCircle = new View(getContext());
    mHoldingCircle.setVisibility(INVISIBLE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mHoldingCircle.setBackground(mHoldingDrawable);
    } else {
        mHoldingCircle.setBackgroundDrawable(mHoldingDrawable);
    }
}
 
开发者ID:dewarder,项目名称:HoldingButton,代码行数:20,代码来源:HoldingButtonLayout.java

示例4: blurAdvanced

import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void blurAdvanced(Context context, Bitmap bkg, View view) {
    if (bkg != null) {
        Bitmap overlay = Bitmap.createBitmap(bkg.getWidth(), bkg.getHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(overlay);
        Paint paint = new Paint();
        paint.setFlags(2);
        canvas.drawBitmap(bkg, 0.0f, 0.0f, paint);
        overlay = FastBlur.doBlur(overlay, (int) 12.0f, true);
        if (LetvUtils.getSDKVersion() >= 16) {
            view.setBackground(new BitmapDrawable(context.getResources(), overlay));
        } else {
            view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay));
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:BlurUtils.java

示例5: setRoundBackground

import android.view.View; //导入方法依赖的package包/类
public static void setRoundBackground(View view, Drawable drawable) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(drawable);
    } else {
        view.setBackgroundDrawable(drawable);
    }
}
 
开发者ID:apg-mobile,项目名称:android-round-textview,代码行数:8,代码来源:DrawableHelper.java

示例6: 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:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Helper.java

示例7: 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:gigabytedevelopers,项目名称:FireFiles,代码行数:11,代码来源:ViewCompat.java

示例8: applyViewTransitBackgroundColor

import android.view.View; //导入方法依赖的package包/类
static void applyViewTransitBackgroundColor(@NonNull View view, int beforeColor,
                                            int afterColor) {
    ColorDrawable[] colors = {new ColorDrawable(beforeColor),
        new ColorDrawable(afterColor)};

    // Transit the background from black
    TransitionDrawable trans = new TransitionDrawable(colors);
    view.setBackground(trans);
    trans.startTransition(BACKGROUND_TRANSITION_DURATION);
}
 
开发者ID:lekaha,项目名称:TwitterizedPhotoView,代码行数:11,代码来源:TwitterizedImageShowingActivity.java

示例9: 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:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:8,代码来源:ViewUtil.java

示例10: setBackground

import android.view.View; //导入方法依赖的package包/类
public static void setBackground(View v, Drawable bgDrawable) {
    if (VERSION.SDK_INT >= 16) {
        v.setBackground(bgDrawable);
    } else {
        v.setBackgroundDrawable(bgDrawable);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:MQUtils.java

示例11: setBackground

import android.view.View; //导入方法依赖的package包/类
public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(drawable);
    } else {
        //noinspection deprecation
        view.setBackgroundDrawable(drawable);
    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:9,代码来源:DrawableUtils.java

示例12: QuickActionViewLayout

import android.view.View; //导入方法依赖的package包/类
public QuickActionViewLayout(Context context, ArrayList<Action> actions, Point centerPoint) {
    super(context);
    mCenterPoint = centerPoint;
    mScrimView = new View(context);
    mScrimView.setBackgroundColor(mScrimColor);
    FrameLayout.LayoutParams scrimParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    addView(mScrimView, scrimParams);
    mIndicatorView = new View(context);
    if (Build.VERSION.SDK_INT >= 16) {
        mIndicatorView.setBackground(mIndicatorDrawable);
    } else {
        mIndicatorView.setBackgroundDrawable(mIndicatorDrawable);
    }
    FrameLayout.LayoutParams indicatorParams = new FrameLayout.LayoutParams(mIndicatorDrawable.getIntrinsicWidth(), mIndicatorDrawable.getIntrinsicHeight());
    addView(mIndicatorView, indicatorParams);
    for (Action action : actions) {
        ConfigHelper helper = new ConfigHelper(action.getConfig(), mConfig);
        ActionView actionView = new ActionView(context, action, helper);
        mActionViews.put(action, actionView);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        addView(actionView, params);
        if (!TextUtils.isEmpty(action.getTitle())) {
            ActionTitleView actionTitleView = new ActionTitleView(context, action, helper);
            actionTitleView.setVisibility(View.GONE);
            mActionTitleViews.put(action, actionTitleView);
            FrameLayout.LayoutParams titleParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            addView(actionTitleView, titleParams);
        }
    }
}
 
开发者ID:ovenbits,项目名称:QuickActionView,代码行数:31,代码来源:QuickActionView.java

示例13: drawBackground

import android.view.View; //导入方法依赖的package包/类
private void drawBackground(View v, int color, boolean isCircle) {
	if (isCircle) {
        GradientDrawable gd = new GradientDrawable();
        gd.setGradientType(GradientDrawable.RADIAL_GRADIENT);
        gd.setColors(new int[]{color, Color.TRANSPARENT });
        gd.setGradientRadius((Defaults.IMAGE_HEIGHT - Defaults.CIRCLE_PADDING)/2);
        v.setBackground(gd);
        
    } else {
        ShapeDrawable oval = new ShapeDrawable (new OvalShape());
        oval.getPaint().setColor(color);
        v.setBackground(oval);
    }
}
 
开发者ID:prashantsaini1,项目名称:titanium-android-imagepicker,代码行数:15,代码来源:ImagePickerActivity.java

示例14: setIndicatorTopContentView

import android.view.View; //导入方法依赖的package包/类
/**
 * set the  View to the indicator top container, not influence indicator arrow ;
 * if indicator type is custom , this method will be not work.
 *
 * @param topContentView the view is inside the indicator TOP part, not influence indicator arrow;
 */
public void setIndicatorTopContentView(@NonNull View topContentView) {
    mTopContentView.removeAllViews();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        topContentView.setBackground(getGradientDrawable());
    } else {
        topContentView.setBackgroundDrawable(getGradientDrawable());
    }
    mTopContentView.addView(topContentView);
}
 
开发者ID:warkiz,项目名称:IndicatorSeekBar,代码行数:16,代码来源:Indicator.java

示例15: setBackgroundDrawableCompat

import android.view.View; //导入方法依赖的package包/类
public static void setBackgroundDrawableCompat(View view, Drawable drawable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(drawable);
    } else {
        //noinspection deprecation
        view.setBackgroundDrawable(drawable);
    }
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:9,代码来源:OsCompat.java


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