本文整理了Java中android.widget.ImageView.setBackgroundResource()
方法的一些代码示例,展示了ImageView.setBackgroundResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setBackgroundResource()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setBackgroundResource
暂无
代码示例来源:origin: lipangit/JiaoZiVideoPlayer
public void setBatteryLevel() {
int percent = LAST_GET_BATTERYLEVEL_PERCENT;
if (percent < 15) {
batteryLevel.setBackgroundResource(R.drawable.jz_battery_level_10);
} else if (percent >= 15 && percent < 40) {
batteryLevel.setBackgroundResource(R.drawable.jz_battery_level_30);
} else if (percent >= 40 && percent < 60) {
batteryLevel.setBackgroundResource(R.drawable.jz_battery_level_50);
} else if (percent >= 60 && percent < 80) {
batteryLevel.setBackgroundResource(R.drawable.jz_battery_level_70);
} else if (percent >= 80 && percent < 95) {
batteryLevel.setBackgroundResource(R.drawable.jz_battery_level_90);
} else if (percent >= 95 && percent <= 100) {
batteryLevel.setBackgroundResource(R.drawable.jz_battery_level_100);
}
}
代码示例来源:origin: koral--/android-gif-drawable
private void postInit(GifViewUtils.GifImageViewAttributes result) {
mFreezesAnimation = result.freezesAnimation;
if (result.mSourceResId > 0) {
super.setImageResource(result.mSourceResId);
}
if (result.mBackgroundResId > 0) {
super.setBackgroundResource(result.mBackgroundResId);
}
}
代码示例来源:origin: stackoverflow.com
private void setFlipperImage(int res) {
Log.i("Set Filpper Called", res+"");
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(res);
viewFlipper.addView(image);
}
代码示例来源:origin: stackoverflow.com
ImageView mImageView= (ImageView)findViewById(R.id.imageview_id);
Bitmap original = BitmapFactory.decodeResource(getResources(),R.drawable.content_image);
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.mask);
Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888);
Canvas mCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(original, 0, 0, null);
mCanvas.drawBitmap(mask, 0, 0, paint);
paint.setXfermode(null);
mImageView.setImageBitmap(result);
mImageView.setScaleType(ScaleType.CENTER);
mImageView.setBackgroundResource(R.drawable.background_frame);
代码示例来源:origin: stackoverflow.com
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_main);
LinearLayout linearLayout1 = (LinearLayout) findViewById(R.id.linearLayout1);
for(int x=0;x<3;x++) {
ImageView image = new ImageView(MainActivity.this);
image.setBackgroundResource(R.drawable.ic_launcher);
linearLayout1.addView(image);
}
}
代码示例来源:origin: stackoverflow.com
private void initializeImageList() {
// TODO Auto-generated method stub
for (int i = 0; i < imageNameDatabase.length; i++) {
map = new HashMap<String, Object>();
map.put("Name", imageNameDatabase[i]);
map.put("Icon", imageIconDatabase[i]);
spinnerList.add(map);
}
ImageView imageView = new ImageView(this);
imageView.setBackgroundResource((spinnerList.get(0).get("Icon"));
spinnerList.get(0).get("Name");
}
代码示例来源:origin: koral--/android-gif-drawable
@Override
public void setBackgroundResource(int resId) {
if (!GifViewUtils.setResource(this, false, resId)) {
super.setBackgroundResource(resId);
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onPausedSeek() {
super.onPausedSeek();
resetNotification();
updateNotification(R.drawable.ic_play_arrow_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_pause_white);
}
代码示例来源:origin: facebook/facebook-android-sdk
private void updateCell(final ImageView imageView, final int position) {
imageView.setImageDrawable(validIcons[board.getValue(position)]);
if (board.isLocked(position)) {
imageView.setBackgroundResource(R.drawable.locked_icon_background);
} else if (board.isEmpty(position)) {
imageView.setBackgroundResource(R.drawable.default_icon_background);
} else if (board.isValid(position)) {
imageView.setBackgroundResource(R.drawable.valid_icon_background);
} else {
imageView.setBackgroundResource(R.drawable.invalid_icon_background);
}
}
代码示例来源:origin: aa112901/remusic
@Override
public void setBackgroundResource(int resId) {
if (mBackgroundHelper != null) {
mBackgroundHelper.setBackgroundResId(resId);
} else {
super.setBackgroundResource(resId);
}
}
代码示例来源:origin: mancj/MaterialSearchBar
private void setupIconRippleStyle() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
TypedValue rippleStyle = new TypedValue();
if (borderlessRippleEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, rippleStyle, true);
} else {
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, rippleStyle, true);
}
navIcon.setBackgroundResource(rippleStyle.resourceId);
searchIcon.setBackgroundResource(rippleStyle.resourceId);
menuIcon.setBackgroundResource(rippleStyle.resourceId);
arrowIcon.setBackgroundResource(rippleStyle.resourceId);
clearIcon.setBackgroundResource(rippleStyle.resourceId);
} else {
Log.w(TAG, "setupIconRippleStyle() Only Available On SDK Versions Higher Than 16!");
}
}
代码示例来源:origin: lipangit/JiaoZiVideoPlayer
@Override
public void showProgressDialog(float deltaX, String seekTime, long seekTimePosition, String totalTime, long totalTimeDuration) {
super.showProgressDialog(deltaX, seekTime, seekTimePosition, totalTime, totalTimeDuration);
if (mProgressDialog == null) {
View localView = LayoutInflater.from(getContext()).inflate(R.layout.jz_dialog_progress, null);
mDialogProgressBar = localView.findViewById(R.id.duration_progressbar);
mDialogSeekTime = localView.findViewById(R.id.tv_current);
mDialogTotalTime = localView.findViewById(R.id.tv_duration);
mDialogIcon = localView.findViewById(R.id.duration_image_tip);
mProgressDialog = createDialogWithView(localView);
}
if (!mProgressDialog.isShowing()) {
mProgressDialog.show();
}
mDialogSeekTime.setText(seekTime);
mDialogTotalTime.setText(" / " + totalTime);
mDialogProgressBar.setProgress(totalTimeDuration <= 0 ? 0 : (int) (seekTimePosition * 100 / totalTimeDuration));
if (deltaX > 0) {
mDialogIcon.setBackgroundResource(R.drawable.jz_forward_icon);
} else {
mDialogIcon.setBackgroundResource(R.drawable.jz_backward_icon);
}
onCLickUiToggleToClear();
}
代码示例来源:origin: lipangit/JiaoZiVideoPlayer
@Override
public void showVolumeDialog(float deltaY, int volumePercent) {
super.showVolumeDialog(deltaY, volumePercent);
if (mVolumeDialog == null) {
View localView = LayoutInflater.from(getContext()).inflate(R.layout.jz_dialog_volume, null);
mDialogVolumeImageView = localView.findViewById(R.id.volume_image_tip);
mDialogVolumeTextView = localView.findViewById(R.id.tv_volume);
mDialogVolumeProgressBar = localView.findViewById(R.id.volume_progressbar);
mVolumeDialog = createDialogWithView(localView);
}
if (!mVolumeDialog.isShowing()) {
mVolumeDialog.show();
}
if (volumePercent <= 0) {
mDialogVolumeImageView.setBackgroundResource(R.drawable.jz_close_volume);
} else {
mDialogVolumeImageView.setBackgroundResource(R.drawable.jz_add_volume);
}
if (volumePercent > 100) {
volumePercent = 100;
} else if (volumePercent < 0) {
volumePercent = 0;
}
mDialogVolumeTextView.setText(volumePercent + "%");
mDialogVolumeProgressBar.setProgress(volumePercent);
onCLickUiToggleToClear();
}
代码示例来源:origin: sunfusheng/StickyHeaderListView
private void addIndicatorImageViews() {
llIndexContainer.removeAllViews();
if (bannerCount < 2) return;
for (int i = 0; i < bannerCount; i++) {
ImageView iv = new ImageView(mActivity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(DensityUtil.dip2px(mActivity, 5), DensityUtil.dip2px(mActivity, 5));
lp.leftMargin = DensityUtil.dip2px(mActivity, (i == 0) ? 0 : 7);
iv.setLayoutParams(lp);
iv.setBackgroundResource(R.drawable.xml_round_orange_grey_sel);
iv.setEnabled(i == 0);
llIndexContainer.addView(iv);
}
}
代码示例来源:origin: aporter/coursera-android
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView imageView = findViewById(R.id.countdown_frame);
imageView.setBackgroundResource(R.drawable.view_animation);
mAnim = (AnimationDrawable) imageView.getBackground();
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onPlaying() {
super.onPlaying();
updateWindowFlags(ONGOING_PLAYBACK_WINDOW_FLAGS);
resetNotification();
updateNotification(R.drawable.ic_pause_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_pause_white);
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
startForeground(NOTIFICATION_ID, notBuilder.build());
lockManager.acquireWifiAndCpu();
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onPaused() {
super.onPaused();
updateWindowFlags(IDLE_WINDOW_FLAGS);
resetNotification();
updateNotification(R.drawable.ic_play_arrow_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_white);
lockManager.releaseWifiAndCpu();
stopForeground(false);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onCompleted() {
super.onCompleted();
updateWindowFlags(IDLE_WINDOW_FLAGS);
resetNotification();
updateNotification(R.drawable.ic_replay_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_replay_white);
lockManager.releaseWifiAndCpu();
stopForeground(false);
}
代码示例来源:origin: ArthurHub/Android-Image-Cropper
imageView.setBackgroundResource(R.drawable.backdrop);
代码示例来源:origin: stackoverflow.com
//...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView animImageView = (ImageView) findViewById(R.id.iv_animation);
animImageView.setBackgroundResource(R.drawable.anim);
animImageView.post(new Runnable() {
@Override
public void run() {
AnimationDrawable frameAnimation =
(AnimationDrawable) animImageView.getBackground();
frameAnimation.start();
}
});
// ... other code ...
}
// ...
内容来源于网络,如有侵权,请联系作者删除!