Android 毕加索占位符比例和适合中心屏幕

Android 毕加索占位符比例和适合中心屏幕,android,animation,placeholder,picasso,Android,Animation,Placeholder,Picasso,我试图实现一个占位符动画与毕加索的动画自定义动画,同时从网上加载。我已经寻找了很多解决方案,但我找不到一种方法来缩小动画的比例并使其居中。结果是,有时动画会拉伸、居中或在一个角上播放 动画图像明显小于图像视图和下载的图像 以下是我当前使用的代码: Picasso.with(getActivity()).load(imageUri).fit()//.placeholder(R.drawable.progress_animation) .placeholder(R.d

我试图实现一个占位符动画与毕加索的动画自定义动画,同时从网上加载。我已经寻找了很多解决方案,但我找不到一种方法来缩小动画的比例并使其居中。结果是,有时动画会拉伸、居中或在一个角上播放

动画图像明显小于图像视图和下载的图像

以下是我当前使用的代码:

Picasso.with(getActivity()).load(imageUri).fit()//.placeholder(R.drawable.progress_animation)
                .placeholder(R.drawable.progress_animation)
                        .into(mIconView);
以下是动画定义:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"



关于如何在毕加索中控制动画比例和位置的任何建议,我都找不到使用fit()或resize()的方法,因为它只影响最终图像,而不影响占位符,尝试使用其中两个会造成冲突

我找到了一种使用进度条并返回的方法

 mProgressView.setVisibility(View.VISIBLE);
            Picasso.with(getActivity()).load(f).fit()

                    .into(mIcon,new Callback() {
                        @Override
                        public void onSuccess() {
                            mProgressView.setVisibility(View.GONE);
                        }

                        @Override
                        public void onError() {
                            // TODO Auto-generated method stub

                        }
                    });
这是布局部分

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"

>
<ImageButton
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:id="@+id/ib_place_dialog_image"
    android:maxHeight="200dp"
    android:layout_gravity="center_horizontal"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />
<ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:scaleX="0.4"
    android:scaleY="0.4"
    android:layout_width="128dp"
    android:layout_height="128dp"
    android:id="@+id/cliff_image_progress_bar"

    android:indeterminateDrawable="@drawable/progress_animation"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

还有动画

   <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selected" android:oneshot="false">

    <item android:drawable="@drawable/frame_0" android:duration="30" />
    <item android:drawable="@drawable/frame_0" android:duration="30" />
<item android:drawable="@drawable/frame_0" android:duration="30" />
<item android:drawable="@drawable/frame_1" android:duration="30" />
<item android:drawable="@drawable/frame_2" android:duration="30" />
<item android:drawable="@drawable/frame_3" android:duration="30" />
<item android:drawable="@drawable/frame_4" android:duration="30" />
<item android:drawable="@drawable/frame_5" android:duration="30" />
<item android:drawable="@drawable/frame_6" android:duration="30" />
<item android:drawable="@drawable/frame_7" android:duration="30" />
<item android:drawable="@drawable/frame_8" android:duration="30" />
<item android:drawable="@drawable/frame_9" android:duration="30" />
<item android:drawable="@drawable/frame_10" android:duration="30" />
<item android:drawable="@drawable/frame_11" android:duration="30" />
<item android:drawable="@drawable/frame_12" android:duration="30" />
<item android:drawable="@drawable/frame_13" android:duration="30" />
<item android:drawable="@drawable/frame_14" android:duration="30" />
<item android:drawable="@drawable/frame_15" android:duration="30" />
<item android:drawable="@drawable/frame_16" android:duration="30" />
<item android:drawable="@drawable/frame_17" android:duration="30" />
<item android:drawable="@drawable/frame_18" android:duration="30" />
<item android:drawable="@drawable/frame_19" android:duration="30" />
<item android:drawable="@drawable/frame_20" android:duration="30" />
<item android:drawable="@drawable/frame_21" android:duration="30" />
<item android:drawable="@drawable/frame_22" android:duration="30" />
<item android:drawable="@drawable/frame_23" android:duration="30" />
<item android:drawable="@drawable/frame_24" android:duration="30" />
<item android:drawable="@drawable/frame_25" android:duration="30" />
<item android:drawable="@drawable/frame_26" android:duration="30" />
<item android:drawable="@drawable/frame_27" android:duration="30" />
<item android:drawable="@drawable/frame_28" android:duration="30" />
<item android:drawable="@drawable/frame_29" android:duration="30" />



</animation-list>

我使用了罗兰·迪瑟姆的代码,但更改了onSucces方法=

在xml中,Post_图像的ScaleType位于中心内部

    Picasso.with(context)
                    .load(imagen)
                    .placeholder(R.drawable.progress_animation)
                    .into(Post_image,new Callback() {
                        @Override
                        public void onSuccess() {
                            Post_image.setScaleType(ImageView.ScaleType.FIT_XY); 
// when the image is loaded it changes the scaletype

                        }

                        @Override
                        public void onError() {
                            // TODO Auto-generated method stub

                        }
                    });   
试试这个

 Picasso.get()
                        .load(source).resize(1650,700)
                        .centerCrop(Gravity.CENTER).into(imageView, new Callback() 

面对同样的问题,看这个谢谢,回调真的很有用。
 Picasso.get()
                        .load(source).resize(1650,700)
                        .centerCrop(Gravity.CENTER).into(imageView, new Callback()