做一个简单的吓人App(页面跳转)

  • 通过页面跳转,在吓人页面放一个恐怖图片并播放尖叫声达到吓人的目的

页面1:广告

  • 第一个页面可以放一个温馨的图片,background设置成图片就可以了
    在这里插入图片描述

    <?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=".headActivity"
        android:background="@mipmap/ha"
        >
    
    </androidx.constraintlayout.widget.ConstraintLayout>
    
  • 创建一个线程延时3秒后跳转到登录界面

    public class headActivity extends AppCompatActivity {
    
        static Activity headActivity;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_head);
    
            headActivity = this;
            final Intent i = new Intent(this,MainActivity.class);
            Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    startActivity(i);
                }
            });
            t.start();
        }
    }
    

页面2:登录

  • 随便做一个粗糙的登录界面
    在这里插入图片描述

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout 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:orientation="vertical"
        tools:context=".MainActivity"
        android:background="#673AB7"
       >
    
    
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="380dp"
        android:background="@mipmap/i02">
    
    
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:layout_alignParentBottom="true"
        android:background="#E91E63">
    
        <EditText
            android:id="@+id/uesr"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginLeft="11dp"
            android:layout_marginTop="30dp"
            android:layout_marginRight="20dp"
            android:layout_toRightOf="@id/te1"
            android:textColor="#F0000000"
            android:textSize="16sp" />
    
        <EditText
            android:id="@+id/pass"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_below="@id/uesr"
            android:layout_marginLeft="11dp"
            android:layout_marginTop="3dp"
            android:layout_marginRight="20dp"
            android:layout_toRightOf="@id/te2"
            android:inputType="textPassword"
            android:textSize="16sp" />
    
        <TextView
            android:id="@+id/te1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="50dp"
            android:textColor="#000000"
            android:textSize="21sp"/>
    
        <TextView
            android:id="@+id/te2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/te1"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="17dp"
            android:text="密码"
            android:textColor="#000000"
            android:textSize="21sp" />
    
        <Button
            android:id="@+id/Bu_1"
            android:layout_width="80dp"
            android:layout_height="60dp"
            android:layout_below="@id/pass"
            android:layout_toRightOf="@id/te2"
            android:layout_marginTop="60dp"
            android:layout_marginLeft="40dp"
            android:text="确定"
            android:textSize="23sp"
            android:background="#BE673AB7"/>
    
        <Button
            android:id="@+id/Bu_2"
            android:layout_width="80dp"
            android:layout_height="60dp"
            android:layout_below="@id/pass"
            android:layout_toRightOf="@id/Bu_1"
            android:layout_marginTop="60dp"
            android:layout_marginLeft="60dp"
            android:text="取消"
            android:textSize="23sp"
            android:background="#BE673AB7" />
    
    </RelativeLayout>
    
    
    </RelativeLayout>
    
  • 先销毁广告页面,判断登录账户和密码,正确后跳转到吓人页面

    public class MainActivity extends Activity {
    
        static Activity MainActivity;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            MainActivity = this;
    
            headActivity h = new headActivity();
            h.headActivity.finish();
    
    
            final Intent i = new Intent(this,twoActivity.class);
    
            final Button bu1 = (Button)findViewById(R.id.Bu_1);
            final Button bu2 = (Button)findViewById(R.id.Bu_2);
            final EditText et1 = (EditText)findViewById(R.id.uesr);
            final EditText et2 = (EditText)findViewById(R.id.pass);
    
            bu1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) { //确定按下后比较字符串是否是设置的用户名和密码
                    if(et1.getText().toString().equals("二哈")&&et2.getText().toString().equals("nb666666")){
                        startActivity(i);
                    }else{
                        Toast.makeText(MainActivity.this, "请输入正确的用户名和密码", Toast.LENGTH_SHORT).show();
                    }
                }
            });
    
            bu2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    et1.setText("");
                    et2.setText("");
                }
            });
        }
    
    }
    
    

页面3:吓人

  • 提前在网上下载好恐怖图片和尖叫音频,音频放在raw文件夹下,图片充满屏幕
    在这里插入图片描述

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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=".twoActivity">
    
    
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            app:srcCompat="@mipmap/xiaoren" />
    
    </LinearLayout>
    
  • 结束上一个页面,利用MediaPlayer播放音频并延时后跳转到登录页面,结束此吓人页面

    public class twoActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_two);
    
            MainActivity m = new MainActivity();
            m.MainActivity.finish();
    
            final Intent i = new Intent(this,MainActivity.class);
            MediaPlayer mp = MediaPlayer.create(this, R.raw.a14367);
    
            mp.start();
    
            Thread t = new Thread(new Runnable() {
                public void run() {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    startActivity(i);
                    finish();
                }
            });
    
            t.start();
        }
    
    
    }
    

❤️ 嘿嘿,怕了吧 ヽ( ̄▽ ̄)ノ

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

money的大雨

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

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

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

打赏作者

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

抵扣说明:

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

余额充值