桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 1

       前言

        由于笔者操作不当,将项目搞崩了,所以打算重写一遍,记下开发过程,作为学习记录。此软件能实现最普通的单词查询功能,也有启动动画、登录注册之类的功能,但笔者目前能力有限,未能将其完善,这是初学阶段的一个半成品,存在不少漏洞,望读者海涵。

导航:

桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The End 导航页及收尾工作

一、前期准备

1.启动动画

(1)创建一个empty activity,命名为Peach Dictionary。

(2)新建一个activity,作为软件启动动画,在manifest中将其设为主界面。

将.welcome设置为主界面

<activity
            android:name=".welcome"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

activity_welcome.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".welcome">

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="@+id/guideline4"
        app:srcCompat="@drawable/img" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.08" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="233dp"
        android:layout_height="179dp"
        android:background="#00FFFFFF"
        android:backgroundTint="#00FFFFFF"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/img_1" />

</androidx.constraintlayout.widget.ConstraintLayout>

在gradle里面添加

apply plugin: 'kotlin-android-extensions'

以运行kotlin代码

welcome.kt(此段引用,侵删)

package com.example.peachdictionary

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.ViewPropertyAnimatorListener
import kotlinx.android.synthetic.main.activity_welcome.*


class welcome : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_welcome)

        //设置图片动画
        ViewCompat.animate(imageView4).apply {
            //缩放,变成1.0倍
            scaleX(1.0f)
            scaleY(1.0f)
            //动画时常1秒
            duration = 1000
            //动画监听
            setListener(object : ViewPropertyAnimatorListener {
                override fun onAnimationEnd(view: View?) { //动画结束
                    //进入主界面,并结束掉该页面
                    startActivity(Intent(this@welcome, MainActivity::class.java))
                    finish()
                }

                override fun onAnimationCancel(view: View?) {
                }

                override fun onAnimationStart(view: View?) {
                }
            })
        }
    }



}

3.在manifest中将主题修改

        android:theme="@style/Theme.AppCompat.Light.NoActionBar">

实现效果:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值