目标效果:
1.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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.weixu.eclipsemole.MainActivity">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/ivZeroZero"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="whackAMole"
android:clickable="false"
android:background="@drawable/emptyhole"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/ivZeroOne"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="whackAMole"
android:clickable="false"
android:background="@drawable/emptyhole"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/ivZeroTwo"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="whackAMole"
android:clickable="false"
android:background="@drawable/emptyhole"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/ivZeroThree"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="whackAMole"
android:clickable="false"
android:background="@drawable/emptyhole"
android:layout_height="match_parent" />