setBackgroundResource
setBackgroundResource只能设置ImageView的android:background属性吗?那如果要设置android:src属性应该怎么设置呢?
setBackgroundResource只能设置ImageView的android:background属性吗?那如果要设置android:src属性应该怎么设置呢?
2016-08-28
// 设置ImageView标签android:src属性,使用setImageResource(@DrawableRes int resId)
// 下面是background
/** * Set the background to a given resource. The resource should refer to * a Drawable object or 0 to remove the background. * @param resid The identifier of the resource. * * @attr ref android.R.styleable#View_background */ @RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
// 下面是src
/**
* Sets a drawable as the content of this ImageView.
*
* <p class="note">This does Bitmap reading and decoding on the UI
* thread, which can cause a latency hiccup. If that's a concern,
* consider using {@link #setImageDrawable(android.graphics.drawable.Drawable)} or
* {@link #setImageBitmap(android.graphics.Bitmap)} and
* {@link android.graphics.BitmapFactory} instead.</p>
*
* @param resId the resource identifier of the drawable
*
* @attr ref android.R.styleable#ImageView_src
*/
@android.view.RemotableViewMethod(asyncImpl="setImageResourceAsync")
public void setImageResource(@DrawableRes int resId)
举报