在Android中显示gif图片

布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/color_ffffff">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="140dp"
        android:textColor="@color/color_a7a6a6"
        android:gravity="center"
        android:textSize="15dp"
        android:text="@string/exit_kindergarten_success_tips"/>
    <RelativeLayout
        android:id="@+id/rl_exit_kindergarten"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="38dp">
        <WebView
            android:id="@+id/iv_exit_kindergarten"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            />
        <TextView
            android:id="@+id/tv_exit_kindergarten"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/iv_exit_kindergarten"
            android:textSize="16dp"
            android:layout_marginTop="17dp"
            android:layout_centerHorizontal="true"
            android:textColor="@color/color_60b166"
            android:text="@string/exiting_kindergarten"/>

    </RelativeLayout>
    <RelativeLayout
        android:id="@+id/rl_exit_kindergarten_success"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:layout_marginTop="38dp">
        <ImageView
            android:id="@+id/iv_exit_kindergarten_success"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/exit_kindergarten_success"
            android:layout_centerHorizontal="true"/>
        <TextView
            android:id="@+id/tv_exit_kindergarten_success"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/iv_exit_kindergarten_success"
            android:textSize="16dp"
            android:layout_marginTop="17dp"
            android:layout_centerHorizontal="true"
            android:textColor="@color/color_60b166"
            android:text="@string/exit_kindergarten_success"/>
        <Button
            android:id="@+id/bt_repeate_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/circle_info_btn_green"
            android:layout_below="@+id/tv_exit_kindergarten_success"
            android:textSize="16dp"
            android:textColor="@color/color_ffffff"
            android:layout_marginLeft="12dp"
            android:layout_marginRight="12dp"
            android:layout_marginTop="72dp"
            android:text="@string/repeat_login"/>
    </RelativeLayout>
</LinearLayout>
代码:

package com.bbtree.publicmodule.paradise.frg;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.bbtree.publicmodule.R;

import net.hyww.wisdomtree.core.base.BaseFrg;
import net.hyww.wisdomtree.core.utils.LogoutUtils;

/**
 * Created by wuqiqi on 2016/1/15.
 */
public class ExitKindergartenSuccessFrg extends BaseFrg{
    private Button tv_repeat_login;
    private RelativeLayout rl_exit_kindergarten;
    private RelativeLayout rl_exit_kindergarten_success;
    private WebView iv_exit_kindergarte;

    @Override
    public int contentView() {
        return R.layout.frg_exit_kindergarten_success;
    }

    @Override
    public boolean titleBarVisible() {
        return false;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        tv_repeat_login= (Button) findViewById(R.id.bt_repeate_login);
        tv_repeat_login.setOnClickListener(this);
        /*final ExitKindergartentLoadingDialog loadingDialog = ExitKindergartentLoadingDialog.newInstance();
        loadingDialog.show(getChildFragmentManager(),"loading");*/
        rl_exit_kindergarten=(RelativeLayout) findViewById(R.id.rl_exit_kindergarten);
        rl_exit_kindergarten_success=(RelativeLayout) findViewById(R.id.rl_exit_kindergarten_success);

        iv_exit_kindergarte=(WebView) findViewById(R.id.iv_exit_kindergarten);
        //iv_exit_kindergarte.loadDataWithBaseURL(null,"<HTML><body bgcolor='#f3f3f3'><div align=center><IMG src='file:///android_asset/gif.gif'/></div></body></html>", "text/html", "UTF-8",null);
        iv_exit_kindergarte.loadDataWithBaseURL(null,"<HTML><body><div align=center><IMG src='file:///android_asset/gif.gif'/></div></body></html>", "text/html", "UTF-8",null);
        new Handler().postDelayed(new Runnable() {

            public void run() {
                // TODO Auto-generated method stub
               // loadingDialog.dismissAllowingStateLoss();
                rl_exit_kindergarten.setVisibility(View.GONE);
                rl_exit_kindergarten_success.setVisibility(View.VISIBLE);
            }

        }, 2000);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        int id=v.getId();
        if(id==R.id.bt_repeate_login){
            getActivity().finish();
            LogoutUtils.getInstance().logout(mContext, false);
        }
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        iv_exit_kindergarte.loadUrl("about:black");
        iv_exit_kindergarte.stopLoading();
        iv_exit_kindergarte=null;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值