首页 > 解决方案 > 如何使用动画制作包含表情符号的自定义警报对话框

问题描述

这是我的 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>

但它不像我想要的那样,所以请帮助我和表情符号正在运行动画。我想做这样的类似

标签: javaandroidandroid-alertdialog

解决方案


第一种方法

嗨,您可以使用该实时表情符号库

第二种方法

您还可以使用 Glide 库来加载 gif

Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);

推荐阅读