Die Anzeige von GIF-in der Bildansicht verwenden Glide
Ich bin mit Glide zum allerersten mal zur Anzeige von GIF-innen Bildansicht. Ich habe kodiert es so, wie es gegeben ist, über mehrere Standorte hinweg. Aber es funktioniert nicht. Ich habe allen den folgenden code:(Bitte lassen Sie mich wissen, wenn ich mich geirrt haben nichts)
Projekt level zu bauen.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:2.1.0-alpha5'
//NOTE: Do not place your application dependencies here; they belong
//in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level zu bauen.gradle-Datei:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.winner.myapplication"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
//compile files('libs/ion-2.1.6.jar')
//compile files('libs/androidasync-2.1.6.jar')
compile 'com.github.bumptech.glide:glide:3.7.0'
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.winner.myapplication.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/layoutImage1"
android:orientation="vertical"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/layoutImage2"
android:orientation="vertical"
android:layout_below="@+id/layoutImage1"
android:layout_gravity="center"
>
<ImageView
android:id="@+id/test_image"
android:layout_width="160dp"
android:layout_height="90dp"
android:scaleType="fitXY"
android:layout_gravity="center"
android:src="@drawable/test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/layoutImage3"
android:orientation="vertical"
android:layout_below="@+id/layoutImage2"
android:layout_gravity="center"
>
<TextView android:text="Hello World!" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="right"
android:id="@+id/submit"
android:text="Submit" />
</LinearLayout>
</RelativeLayout>
Tätigkeit Java-code:
package com.example.winner.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(onClickSubmit);
}
View.OnClickListener onClickSubmit = new View.OnClickListener() {
@Override
public void onClick(View v) {
ImageView iView = (ImageView) findViewById(R.id.test_image);
Glide.with(getApplicationContext()).
load("http://i.imgur.com/1ALnB2s.gif").into(iView);
}
};
}
Sehe ich nicht das GIF-Bild nach dem Klick auf den Submit-button.
ich denke, es könnte nützlich sein, stackoverflow.com/questions/31082330/...
InformationsquelleAutor | 2016-04-11
Du musst angemeldet sein, um einen Kommentar abzugeben.
Als Glide-Dokumentation sagt,
Die Sie verwenden können .asGif() erzwingen, dass die Bibliothek zum laden eines animierten gif-und scheitern, wenn es nicht ist :
Ich würde empfehlen Sie, um die folgenden
Für mehr Informationen, bitte Lesen Sie Gleiten Beispiele zum laden von Gif
https://github.com/bumptech/glide/wiki
Code-Beispiel funktioniert gut !
InformationsquelleAutor Copy
Können Sie gehen mit diesem. Es funktionierte für mich. Ich hoffe, es wird auch für Sie arbeiten.
Es funktioniert sowohl für Bilder sowie gifs.
InformationsquelleAutor Saket Kumar
Laden Sie die gif mit glide,glide dauert nur wenige Sekunden, um zu verarbeiten gif. So, das Bild kann nur geladen werden, nach dieser Zeit.So, bedeuten, während u können, verwenden Sie Platzhalter.
Gleiten.mit(dieser).laden("http://i.imgur.com/1ALnB2s.gif").asGif().Platzhalter(R. drawable.any_normal_image.png).in(iView);
InformationsquelleAutor akhilsreekar
Ich hatte Mühe, Glide Anzeige einer lokalen gif (drawables-Ordner), die ich hatte, und für mich war das problem, dass ich die Erweiterung (.gif) " im Dateinamen. Nachdem ich entfernt die Erweiterung, schließlich ist das Bild angezeigt. Nicht sicher, ob das auch gilt für eine URL, aber dachte, ich würde Aktie trotzdem für Leute Googeln.
Nicht funktioniert hat:
Funktionierte:
InformationsquelleAutor yousefnjr