1.主布局文件
主Activity文件
Android Manifest添加
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_marginLeft="40dp"
android:layout_marginTop="10dp"
android:contentDescription="@string/app_name"
android:src="@drawable/mainbody" />
<ImageButton
android:id="@+id/mainpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="45dp"
android:layout_marginLeft="13dp"
android:background="@drawable/bigtab"
android:contentDescription="@string/app_name"
android:src="@drawable/main" />
<ImageButton
android:id="@+id/timepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="103dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/time" />
<ImageButton
android:id="@+id/calenpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="160dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/calen" />
<ImageButton
android:id="@+id/recelpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="217dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/recel" />
<ImageButton
android:id="@+id/setpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="274dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/set" />
</RelativeLayout>
跳转页布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity" >
<ImageView
android:id="@id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_marginLeft="40dp"
android:layout_marginTop="10dp"
android:contentDescription="@string/app_name"
android:src="@drawable/mainbody" />
<ImageButton
android:id="@id/mainpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="46dp"
android:layout_marginLeft="17dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/main" />
<ImageButton
android:id="@id/timepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_marginTop="102dp"
android:background="@drawable/bigtab"
android:contentDescription="@string/app_name"
android:src="@drawable/time" />
<ImageButton
android:id="@id/calenpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="160dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/calen" />
<ImageButton
android:id="@id/recelpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="217dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/recel" />
<ImageButton
android:id="@id/setpage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:layout_marginTop="274dp"
android:background="@drawable/littletab"
android:contentDescription="@string/app_name"
android:src="@drawable/set" />
</RelativeLayout>
主Activity文件
package com.example.time_manager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageButton button_2 = (ImageButton) findViewById(R.id.timepage);
button_2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent_time = new Intent(MainActivity.this,TimeActivity.class);
startActivity(intent_time);
}
});
ImageButton button_3 = (ImageButton) findViewById(R.id.calenpage);
button_3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent_calen = new Intent(MainActivity.this,CalenActivity.class);
startActivity(intent_calen);
}
});
ImageButton button_4 = (ImageButton) findViewById(R.id.recelpage);
button_4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent_recel = new Intent(MainActivity.this,RecelActivity.class);
startActivity(intent_recel);
}
});
ImageButton button_5 = (ImageButton) findViewById(R.id.setpage);
button_5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent_set = new Intent(MainActivity.this,SetActivity.class);
startActivity(intent_set);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Android Manifest添加
<activity
android:name=".TimeActivity"
android:label="@string/app_name" />