要求:有背景音乐,按钮切换图片并带图片说明
效果:
实现:
创建raw目录,将音频文件放入raw目录
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img1"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btnLast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="上一张"
android:textSize="20sp