效果图:
话不多说,直接上源代码:
主界面:activity.main.xml
<?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"
android:background="@mipmap/bg4"
android:id="@+id/root"
tools:context=".MainActivity">
<ImageView
android:id="@+id/jk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/jk"/>
</LinearLayout>
MainAcitivty.class
package net.example.touch;
import androidx.appcompat.app