0
我是Android的新手。以下是我複製並略微修改的示例代碼,但它無法爲gif圖像製作動畫。它只是在我的應用程序中顯示爲靜態圖像。 gifImage不是動畫。我甚至試圖初始化控制器兩次。Android壁畫庫gif沒有動畫
private void findViews() {
button = (Button) findViewById(R.id.button);
sdvImage = (SimpleDraweeView) findViewById(R.id.sdv_image);
roundBorderImage = (SimpleDraweeView) findViewById(R.id.round_border);
circleImage = (SimpleDraweeView) findViewById(R.id.circle);
fullCustomImage = (SimpleDraweeView) findViewById(R.id.full_custom_image);
gifImage = (SimpleDraweeView)findViewById(R.id.gifimage);
} DraweeController controller;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
setContentView(R.layout.activity_main);
findViews();
final Uri imageUri = Uri.parse("https://lh3.googleusercontent.com/-voUmhKJzNHc/VSJaPfSJ2pI/AAAAAAAABKw/-oFVzRZxI40/w140-h105-p/fresh_green_grass_bokeh-wallpaper-1024x768.jpg");
// final Uri imageUri = Uri.parse()
final Uri gifURI = Uri.parse("http://s3.amazonaws.com/giphygifs/media/4aBQ9oNjgEQ2k/giphy.gif");
controller = Fresco.newDraweeControllerBuilder()
.setUri(gifURI)
.setAutoPlayAnimations(true)
.build();
// mSimpleDraweeView.setController(controller);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// sdvImage.setController(controller);
sdvImage.setImageURI(imageUri);
roundBorderImage.setImageURI(imageUri);
circleImage.setImageURI(imageUri);
fullCustomImage.setImageURI(imageUri);
gifImage.setController(controller);
gifImage.setImageURI(gifURI);
}
});
}
PS-我gradle這個文件我有下面的行,以及編譯壁畫的行 compile'com.facebook.fresco:animat ED-GIF:0.12.0' –