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?
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.
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.
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.
Drawable drawable = ResourcesCompat. getDrawable (res, R. drawable. myimage, null);
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.
You can use BACKGROUND FOR ALL THE VIEWS.. But You can use SRC only for ImageView & ImageButton.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With