白云点缀的蓝 发表于 2020-7-22 20:47

教大家编写表白软件

本帖最后由 starry、星空 于 2020-7-22 20:51 编辑

大家好,我是starry、星空,今天我的教程是关于安卓的表白软件制作,
编写工具是Android studio,大家可以用手机端的aide做或者用MT管理器修改
apk已经编译好。软件是进入就播放背景音乐,并且慢慢的像打字一样显示表白内容
软件是全屏,去标题,还有背景图片,大家可以自己手动调整字体大小,颜色等

主要代码如下
package com.example.biaobai;

import androidx.appcompat.app.AppCompatActivity;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private static TextView text;
    private static String biaobai="你是大树我是小鸟,我要紧紧把你依靠;你是太阳我是秧苗,你要时常把我普照;你是细雨我是小草,你会冲淡我的孤傲;你是大海我是航标,你的劳苦我都知晓;你的祝福我都收到,你的关爱我最自豪!";
    private static int length;
    private static String dazi;
    private static int n;
    private static MediaPlayer mediaPlayer;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
      text=findViewById(R.id.textView);//获取控件
      length=biaobai.length();//获取表白内容长度
      mediaPlayer=MediaPlayer.create(this, R.raw.xiehou);
       // mediaPlayer.start();//播放音乐
       // typeword();//调用打字
      yanchi();


    }
    public static void typeword(){

      new Thread(new Runnable() {
            @Override
            public void run() {
                dazi=biaobai.substring(0,n);
                text.setText(dazi);
                n=n+1;
                try {
                  Thread.sleep(200);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                if(n<length){

                  typeword();
                }
            }
      }).start();



    }
    public static void yanchi(){

      new Thread(new Runnable() {
            @Override
            public void run() {
                mediaPlayer.start();
                try {
                  Thread.sleep(2400);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                typeword();
            }
      }).start();
    }
}
布局代码
<?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"
    android:background="@drawable/beijin"
    tools:context=".MainActivity">


    <TextView
      android:id="@+id/textView"
      android:layout_width="409dp"
      android:layout_height="729dp"
      android:textColor="@color/ys"
      android:textSize="30dp"
      tools:layout_editor_absoluteX="1dp"
      tools:layout_editor_absoluteY="1dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
配置文件代码<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.biaobai">

    <application
      android:allowBackup="true"
      android:icon="@drawable/jinglinglurai"
      android:label="@string/app_name"
      android:roundIcon="@drawable/jinglinglurai"
      android:supportsRtl="true"
      android:theme="@style/Theme.AppCompat.NoActionBar">

      <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
下载地址:链接:https://pan.baidu.com/s/1xVAqE3K66eV_WTlObCPz5A

回复可见提取码
**** Hidden Message *****





pipi9 发表于 2020-7-23 11:06

脑婆牛批

PLMDTK 发表于 2020-7-23 18:27

前排围观,感谢感谢

duxiaosohu 发表于 2020-7-27 13:02

下载看一下

a1545515 发表于 2020-7-28 19:51

谢谢6666666

花零水落 发表于 2020-8-19 15:16

好东西666666666666

花零水落 发表于 2020-8-19 15:17

谢谢了佬哥好东西东西

花零水落 发表于 2020-8-19 15:18

谢谢了佬哥好东西东西

lov0996 发表于 2020-8-26 12:31

感谢楼主分享,我试试看效果如何~~~

就玩一会吧 发表于 2020-9-8 09:15

有没有不需要安装的就能用的,现在苹果用的不少。
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: 教大家编写表白软件