Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference: android:background and android:src? [duplicate]

Possible Duplicate:
What is the difference between src and background of ImageView

What is the difference between android:background and android:src? Is their working same?

like image 362
DuyguK Avatar asked Feb 27 '12 00:02

DuyguK


People also ask

What is difference between SRC and background in Android?

All views can take a background image. The src to an ImageView has additional features: different scaling types. adjustViewBounds for setting bounds to match image dimensions.

What is difference between background and backgroundTint in Android?

If you have a widget that has a png/vector drawable background set by android:background , and you want to change its default color, then you can use android:backgroundTint to add a shade to it.

What is SRC in ImageView?

Below is the example code in which we set the id of a image view. <ImageView android:id="@+id/simpleImageView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> 2. src: src is an attribute used to set a source file or you can say image in your imageview to make your layout attractive.

Which function is used to load a drawable image resource?

Drawable drawable = ResourcesCompat. getDrawable (res, R. drawable. myimage, null);


2 Answers

android:background exists for all the view. As the name suggests this is what is going to be there in the background.

android:src exists for ImageViews and its subclasses. You can think of this as the foreground. Because ImageView is a subclass of View you even have android:background for that.

  • If the foreground is smaller than background, the background portion which is not covered by the foreground would be visible.
  • Also, you can use transparency in the foreground in which case the background would be visible(transparently).
like image 90
500865 Avatar answered Oct 28 '22 17:10

500865


You can use BACKGROUND FOR ALL THE VIEWS.. But You can use SRC only for ImageView & ImageButton.....

like image 29
Mohanish Avatar answered Oct 28 '22 15:10

Mohanish