Emotion Rating View 开源项目教程

Emotion Rating View 开源项目教程

emotion-rating-viewA library for animated rating view in Android apps.项目地址:https://gitcode.com/gh_mirrors/em/emotion-rating-view

1. 项目的目录结构及介绍

Emotion Rating View 项目的目录结构如下:

emotion-rating-view/
├── app/
│   ├── gradle/
│   │   └── wrapper/
│   ├── src/
│   └── build.gradle
├── gradle/
│   └── wrapper/
├── library/
│   ├── src/
│   └── build.gradle
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

目录结构介绍

  • app/: 包含示例应用程序的代码。

    • gradle/wrapper/: Gradle 包装器文件。
    • src/: 示例应用程序的源代码。
    • build.gradle: 示例应用程序的构建脚本。
  • gradle/: Gradle 包装器文件。

    • wrapper/: Gradle 包装器文件。
  • library/: 包含库的代码。

    • src/: 库的源代码。
    • build.gradle: 库的构建脚本。
  • .gitignore: Git 忽略文件。

  • LICENSE: 项目许可证。

  • README.md: 项目自述文件。

  • build.gradle: 根项目的构建脚本。

  • gradle.properties: Gradle 属性文件。

  • gradlew: Gradle 包装器脚本(Unix)。

  • gradlew.bat: Gradle 包装器脚本(Windows)。

  • settings.gradle: 项目设置文件。

2. 项目的启动文件介绍

项目的启动文件主要是 app/src/main/java/.../MainActivity.javaapp/src/main/res/layout/activity_main.xml

MainActivity.java

这是示例应用程序的主活动文件,负责初始化和设置 Emotion Rating View 库。

package com.dm.emotionrating.app;

import android.os.Bundle;
import android.widget.RatingBar;
import androidx.appcompat.app.AppCompatActivity;
import com.dm.emotionrating.library.EmotionView;
import com.dm.emotionrating.library.GradientBackgroundView;

public class MainActivity extends AppCompatActivity {

    private EmotionView emotionView;
    private GradientBackgroundView gradientBackgroundView;
    private RatingBar ratingView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        emotionView = findViewById(R.id.emotionView);
        gradientBackgroundView = findViewById(R.id.gradientBackgroundView);
        ratingView = findViewById(R.id.ratingView);

        ratingView.setOnRatingBarChangeListener((ratingBar, rating, fromUser) -> {
            emotionView.setRating(rating);
            gradientBackgroundView.changeBackground(rating);
        });
    }
}

activity_main.xml

这是示例应用程序的主布局文件,定义了 Emotion Rating View 库的视图。

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.dm.emotionrating.library.GradientBackgroundView
        android:id="@+id/gradientBackgroundView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.dm.emotionrating.library.EmotionView
        android:id="@+id/emotionView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="48dp"
        android:layout_marginLeft="48

emotion-rating-viewA library for animated rating view in Android apps.项目地址:https://gitcode.com/gh_mirrors/em/emotion-rating-view

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

幸愉旎Jasper

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值