如何使用动画制作自定义警报对话框中包含的表情符号

时间:2019-06-04 12:43:58

标签: java android alertdialog

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

但是它与我想要的不相似,所以请帮助我和表情符号正在运行动画。 I want to make similar like this

2 个答案:

答案 0 :(得分:2)

第一种方法

嗨,您可以使用该库Live emojis

第二种方法

您还可以使用Glide库加载gif

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

答案 1 :(得分:1)

  1. 您可以在下面查看在Android中创建自定义对话框的教程。

    Create a custom Dialog Box

  2. 学习了如何创建自定义对话框后,您可以使用https://github.com/airbnb/lottie-android中的p之类的库。

  3. 您可以在其网站https://lottiefiles.com/

  4. 上找到Lottie的动画