本文整理了Java中android.widget.ImageView.getBackground()
方法的一些代码示例,展示了ImageView.getBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getBackground()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getBackground
暂无
代码示例来源:origin: stackoverflow.com
ImageView imgIcon = findViewById(R.id.imgIcon);
GradientDrawable backgroundGradient = (GradientDrawable)imgIcon.getBackground();
backgroundGradient.setColor(getResources().getColor(R.color.yellow));
代码示例来源:origin: stackoverflow.com
final ImageView tweenImage = (ImageView) findViewById(R.id.imageView1);
tweenImage.setBackgroundResource(R.anim.cubicfacetween);
tweenImage.post(new Runnable() {
@Override
public void run() {
AnimationDrawable frameAnimation =
(AnimationDrawable) tweenImage.getBackground();
frameAnimation.start();
}
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
/**
* 初始化加载动画
*/
private void initAnimation() {
mVideoPrepareLayout.setVisibility(View.VISIBLE);
startText = startText + "【完成】\n解析视频地址...【完成】\n全舰弹幕填装...";
mPrepareText.setText(startText);
mLoadingAnim = (AnimationDrawable) mAnimImageView.getBackground();
mLoadingAnim.start();
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
private void startAnim() {
mAnimViewBackground = (AnimationDrawable) mAnimView.getBackground();
mAnimViewBackground.start();
}
代码示例来源: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: jaydenxiao2016/AndroidFire
@Override
public boolean setUp(String url, int screen, Object... objects) {
if (objects.length == 0) return false;
if (super.setUp(url, screen, objects)) {
if (pauseSwitchCoverBitmap != null && coverImageView.getBackground() == null) {
coverImageView.setBackgroundColor(Color.parseColor("#222222"));//防止在复用的时候导致,闪一下上次暂停切换缓存的图的问题
}
titleTextView.setText(objects[0].toString());
if (currentScreen == SCREEN_WINDOW_FULLSCREEN) {
fullscreenButton.setImageResource(R.drawable.jc_shrink);
backButton.setVisibility(View.VISIBLE);
tinyBackImageView.setVisibility(View.INVISIBLE);
} else if (currentScreen == SCREEN_LAYOUT_LIST) {
fullscreenButton.setImageResource(R.drawable.jc_enlarge);
backButton.setVisibility(View.GONE);
tinyBackImageView.setVisibility(View.INVISIBLE);
} else if (currentScreen == SCREEN_WINDOW_TINY) {
tinyBackImageView.setVisibility(View.VISIBLE);
setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
}
return true;
}
return false;
}
代码示例来源:origin: koral--/android-gif-drawable
static GifImageViewAttributes initImageView(ImageView view, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
if (attrs != null && !view.isInEditMode()) {
final GifImageViewAttributes viewAttributes = new GifImageViewAttributes(view, attrs, defStyleAttr, defStyleRes);
final int loopCount = viewAttributes.mLoopCount;
if (loopCount >= 0) {
applyLoopCount(loopCount, view.getDrawable());
applyLoopCount(loopCount, view.getBackground());
}
return viewAttributes;
}
return new GifImageViewAttributes();
}
代码示例来源: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 ...
}
// ...
代码示例来源:origin: Aspsine/SwipeToLoadLayout
@Override
protected void onFinishInflate() {
super.onFinishInflate();
ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
ivSpeed = (ImageView) findViewById(R.id.ivSpeed);
mAnimDrawable = (AnimationDrawable) ivRefresh.getBackground();
mTwinkleAnim = AnimationUtils.loadAnimation(getContext(), R.anim.twinkle);
}
代码示例来源:origin: stackoverflow.com
loadingViewAnim = (AnimationDrawable) loadigIcon.getBackground();
代码示例来源:origin: robolectric/robolectric
@Test
public void testViewBackgroundIdIsSet() throws Exception {
View mediaView = inflate(layout.main);
ImageView imageView = mediaView.findViewById(R.id.image);
assertThat(shadowOf(imageView.getBackground()).getCreatedFromResId())
.isEqualTo(R.drawable.image_background);
}
代码示例来源:origin: stackoverflow.com
ImageView iv = (ImageView) findViewById(R.id.splashImageView);
Drawable d =iv.getBackground();
BitmapDrawable bitDw = ((BitmapDrawable) d);
Bitmap bitmap = bitDw.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] imageInByte = stream.toByteArray();
System.out.println("........length......"+imageInByte);
ByteArrayInputStream bis = new ByteArrayInputStream(imageInByte);
代码示例来源:origin: stackoverflow.com
ImageView iv = (ImageView) findViewById(R.id.splashImageView);
Drawable d = iv.getBackground();
BitmapDrawable bitDw = ((BitmapDrawable) d);
Bitmap bitmap = bitDw.getBitmap();
System.out.println(".....d....."+d);
System.out.println("...bitDw...."+bitDw);
System.out.println("....bitmap...."+bitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] imageInByte = stream.toByteArray();
代码示例来源:origin: stackoverflow.com
ImageView iv = new ImageView(this);
iv.setBackgroundResource(R.drawable.anim_progress);
final AnimationDrawable mailAnimation = (AnimationDrawable) iv.getBackground();
iv.post(new Runnable() {
public void run() {
if ( mailAnimation != null ) mailAnimation.start();
}
});
代码示例来源:origin: tommybuonomo/dotsindicator
private void refreshDotsColors() {
if (dots == null) {
return;
}
for (int i = 0; i < dots.size(); i++) {
ImageView elevationItem = dots.get(i);
DotsGradientDrawable background = (DotsGradientDrawable) elevationItem.getBackground();
if (i == viewPager.getCurrentItem() || (progressMode && i < viewPager.getCurrentItem())) {
background.setColor(selectedDotColor);
} else {
background.setColor(dotsColor);
}
elevationItem.setBackground(background);
elevationItem.invalidate();
}
}
代码示例来源:origin: tommybuonomo/dotsindicator
setDotWidth(nextDot, nextDotWidth);
DotsGradientDrawable selectedDotBackground = (DotsGradientDrawable) selectedDot.getBackground();
DotsGradientDrawable nextDotBackground = (DotsGradientDrawable) nextDot.getBackground();
代码示例来源:origin: weexteam/weex-hackernews
@Test
@PrepareForTest(WXImageView.class)
public void testSetBackgroundColor() throws Exception {
ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
mWXImage.mHost = imageView;
mWXImage.setBackgroundColor("#FFFFFF");
Drawable drawable = mWXImage.getHostView().getBackground();
assertEquals(drawable instanceof BorderDrawable, true);
}
代码示例来源:origin: stackoverflow.com
setContentView(R.layout.splashscreen);
final ImageView splashImage = (ImageView) findViewById(R.splash.ImageView);
splashImage.setBackgroundResource(R.drawable.splash);
splashAnimation = (AnimationDrawable) splashImage.getBackground();
splashAnimation.start();
代码示例来源:origin: stackoverflow.com
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView i = (ImageView)findViewById(R.id.img1);
i.setBackgroundResource(R.drawable.gif);
AnimationDrawable pro = (AnimationDrawable)i.getBackground();
pro.start();
}
}
代码示例来源:origin: stackoverflow.com
final ImageView pygalo = (ImageView) findViewById(R.id.imageanimation);
pygalo.setBackgroundResource(R.anim.animation);
final AnimationDrawable pygaloanimation = (AnimationDrawable) pygalo.getBackground();
pygalo.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View vp) {
pygaloanimation.stop();
pygaloanimation.start();
}
});
内容来源于网络,如有侵权,请联系作者删除!