- 通过页面跳转,在吓人页面放一个恐怖图片并播放尖叫声达到吓人的目的
页面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(); } }
❤️ 嘿嘿,怕了吧 ヽ( ̄▽ ̄)ノ