我正在使用Picasso使用URL拍摄图像。我试图将图像视图的背景图像设置为相同的图像。我能够获得图像但是没有办法将相同的图像设置为imageview的背景。 我目前的代码如下:
ActivityLayout
var test=function(a,b){
return parseFloat(a + "." + (b>10||b===0?b:(b+"5"))).toFixed(2);
};
console.log(test(1,23));
console.log(test(10,4));
console.log(test(0,0));
//That will always work
//THATS IF YOU WANT THE 10.45 ROUND EFFECT THAT YOU QUEST
活动中的实施:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
>
<ImageView
android:id="@+id/main.backdrop"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center"
android:scaleType="centerInside"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
...
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:1)
我认为你创建了new Target
https://stackoverflow.com/questions/20181491/use-picasso-to-get-a-callback-with-a-bitmap
private Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
imageView.setImageBitmap(bitmap);
// edit your bitmap and set as background
BitmapDrawable ob = new BitmapDrawable(getResources(), bitmap);
imageView.setBackgroundDrawable(ob);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
}