Picasso 加载图片到ImageView 或者自己的自定义View都是可以直接调用对应API的,但是用into(0直接也加载到RelatieLayout就不好使了,可以这样来:
Picasso.with(getActivity()).load(R.drawable.mine_top_bg).into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { if (android.os.Build.VERSION.SDK_INT > 15) { rl_mine_top.setBackground(new BitmapDrawable(getActivity().getResources(), bitmap)); } else { rl_mine_top.setBackgroundDrawable(new BitmapDrawable(getActivity().getResources(), bitmap)); } } @Override public void onBitmapFailed(final Drawable errorDrawable) { } @Override public void onPrepareLoad(final Drawable placeHolderDrawable) { } });
时间: 2024-10-26 10:53:57