项目目录
MainActivity.java
package top.gaojc.myplumblossom; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
activity_main.xml
<?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" tools:context=".MainActivity"> <!-- 中间的--> <ImageView android:id="@+id/center" android:layout_width="200dp" android:layout_height="80dp" android:src="@drawable/three" android:layout_centerInParent="true"/> <!-- 上边--> <ImageView android:layout_width="80dp" android:layout_height="200dp" android:src="@drawable/one" android:layout_above="@id/center" android:layout_centerHorizontal="true"/> <!-- 左边--> <ImageView android:layout_width="80dp" android:layout_height="200dp" android:src="@drawable/two" android:layout_toLeftOf="@id/center" android:layout_centerVertical="true"/> <!-- 右边--> <ImageView android:layout_width="80dp" android:layout_height="200dp" android:src="@drawable/four" android:layout_toRightOf="@id/center" android:layout_centerVertical="true"/> <!-- 下边--> <ImageView android:layout_width="80dp" android:layout_height="200dp" android:src="@drawable/five" android:layout_below="@id/center" android:layout_centerHorizontal="true"/> </RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="top.gaojc.myplumblossom"> <application android:allowBackup="true" android:icon="@drawable/four" android:label="@string/app_name" android:roundIcon="@drawable/four" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>