gpt4 book ai didi

Android Fresco 库gif没有动画

转载 作者:行者123 更新时间:2023-11-29 17:13:47 30 4
gpt4 key购买 nike

我是安卓新手。下面是我复制并稍微修改的示例代码,但它无法为 gif 图像设置动画。它只是在我的应用程序中显示为静态图像。 gifImage 没有动画。我什至尝试两次初始化 Controller 。

    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);
}
});
}

最佳答案

你能试试 0.14.1 版吗?以下代码对我有用:

Gradle :

compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'

布局中的某处:

<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/drawee"
android:layout_width="46dp"
android:layout_height="46dp"
/>

在 Java 中:

SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(R.id.drawee);
simpleDraweeView.setController(
Fresco.newDraweeControllerBuilder()
.setImageRequest(ImageRequest.fromUri("http://s3.amazonaws.com/giphygifs/media/4aBQ9oNjgEQ2k/giphy.gif"))
.setAutoPlayAnimations(true)
.build());

关于Android Fresco 库gif没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39850347/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com