Sunday, January 26, 2014

In ImageView method setBackgroundColor () Why does not work?


            
Code is as follows: Will the ImageView method setBackgroundColor () Why does not work?
 
switcher.setFactory (new ViewFactory ()
{
/ * (Non-Javadoc)
* @ See android.widget.ViewSwitcher.ViewFactory # makeView ()
* /
@ Override
public View makeView ()
{
ImageView imageView = new ImageView (gridview.this);
imageView.setBackgroundColor (0xffffff);
/ / ImageView.setBackgroundResource (R.drawable.tianxie);
imageView.setScaleType (ImageView.ScaleType.FIT_END);
imageView.setLayoutParams (new ImageSwitcher.LayoutParams (
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
return imageView;
}
});

Reply:
ImageView set the background color
ImageView.setBackgroundColor (android.graphics.Color.parseColor ("# ffffff"));
ImageView.setBackgroundColor (Color.RED);
ImageView.setBackgroundColor (Color.rgb (255, 0, 0));
Reply:
Thank you for your reply!
Will it is not directly pass hexadecimal value?
cited a floor reply:
ImageView set the background color
ImageView.setBackgroundColor (android.graphics.Color.parseColor ("# ffffff"));
ImageView.setBackgroundColor (Color.RED);
ImageView.setBackgroundColor (Color.rgb (255, 0, 0));

Reply:
4 bytes corresponding to low opacity colors red, green, blue four components, 0xFFFFFF corresponding opacity component is zero, so the back no matter what the background is transparent. 0xFFFFFFFF is a white, 0x80FFFFFF is translucent white. Color.rgb () will automatically be set to read 255 opaque, and parse the string color "# FFFFFF" can be judged only gives the three components will automatically set the opacity of 255. For integer 0xFFFFFF and 0x00FFFFFF is the same, is completely transparent.
Reply:
Color is to begin with a #
Reply:
reference to the third floor bluewanderer reply: corresponding to low
four colors red, green and blue bytes opacity four components, 0xFFFFFF corresponding opacity component is 0, so the back no matter what the background is transparent. 0xFFFFFFFF is a white, 0x80FFFFFF is translucent white. Color.rgb () will automatically be set to read 255 opaque, and parse the string color "# FFFFFF" can be judged only gives the three components will automatically set the opacity of 255. For integer 0xFFFFFF and 0x00FFFFFF is the same, is completely transparent.


Thank expert opinions

No comments:

Post a Comment