java - 如何使用动画制作包含表情符号的自定义警报对话框
问题描述
这是我的 xml 布局:
<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="90dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/lyt_like"
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Like"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:id="@+id/lyt_love"
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Love"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Sad"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="match_parent"
android:layout_height="1dp">
</View>
<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="90dp"
android:orientation="horizontal">
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="laugh"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Wow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="match_parent"
android:layout_height="1dp">
</View>
<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="90dp"
android:orientation="horizontal">
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Me Too"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Don't Worry"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
<LinearLayout
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="@drawable/save"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:text="Consult Doctor"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/bg_screen2"
android:layout_width="1dp"
android:layout_height="match_parent">
</View>
</LinearLayout>
解决方案
第一种方法
嗨,您可以使用该实时表情符号库
第二种方法
您还可以使用 Glide 库来加载 gif
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
推荐阅读
- mysql - 为什么我的查询结果在页面中这么慢,而查询本身却很快
- php - 使用 php 来自 API 的 curl 请求
- c++ - 如何检查 void* 指针下的运行时类型(允许简单类型,无基类)?
- mysql - 如何获取 MySQL 数据库的创建日期?
- python - 如何找到一个字符串与多个字符串列表的匹配项
- database - 无法连接到 postgresql 中的数据库
- git - 当使用 Git Flow 管理发布与开发时,如何追溯应用修补程序?
- c# - 如何在数据库中插入 json 字符串
- c# - 在 C# 中模拟用于单元测试的 tgz、tar、gz 文件
- php - 如何解决 PHPmailer 中的 undefined:index 和以下错误?