【Android开发】范例2-个性游戏开始界面

实现一个个性的游戏界面:

素材:

实例代码:
MainActivity:

package com.example.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.FrameLayout;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

	}
}

res/drawable/文件夹下放置有background.jpg、img_top.jpg、in.png、exit.png、music.png、stop.png、setting.png图片待用

res/layout/main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:orientation="vertical"
	android:background="@drawable/background"
        android:screenOrientation="landscape" >
	<!-- 添加顶部图片 -->
	<ImageView android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:scaleType="centerCrop"
	    android:layout_gravity="center_horizontal"
	    android:layout_weight="1"
	    android:src="@drawable/img_top"/>
	<RelativeLayout android:layout_width="match_parent"
	    android:layout_height="wrap_content"
	    android:layout_weight="2"
	    android:id="@+id/relativelayout1">
	    <!-- 添加中间位置的图片按钮 -->
	    <ImageView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/image1"
	        android:src="@drawable/in"
	        android:layout_centerInParent="true"/>
	     <!-- 添加上方显示的图片按钮 -->
	     <!-- alignLeft是和某个组件左边对其,而toLeftOf是在某控件左边 -->
	    <ImageView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/image2"
	        android:src="@drawable/setting"
	        android:layout_above="@id/image1"
	        android:layout_alignRight="@id/image1"/>
	     <!-- 添加下方位置的图片按钮 -->
	    <ImageView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/image3"
	        android:src="@drawable/stop"
	        android:layout_below="@id/image1"
	        android:layout_alignLeft="@id/image1"/>
	     <!-- 添加左侧位置的图片按钮 -->
	    <ImageView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/image4"
	        android:src="@drawable/exit"
	        android:layout_toLeftOf="@id/image1"
	        android:layout_alignTop="@id/image1"/>
	     <!-- 添加右侧位置的图片按钮 -->
	    <ImageView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/image5"
	        android:src="@drawable/music"
	        android:layout_toRightOf="@id/image1"
	        android:layout_alignTop="@id/image1"/>
	</RelativeLayout>
</LinearLayout>


转载请注明出处:http://blog.csdn.net/acmman/article/details/44754583

时间: 2024-07-29 13:42:32

【Android开发】范例2-个性游戏开始界面的相关文章

求高手推荐几本ANDROID开发初学者书籍

问题描述 本人有点J2ME基础.ANDROID完全不懂,连安装环境都不会.最好能是最浅显的入门书.学过用过的朋友推荐几本. 解决方案 解决方案二:推荐推荐我顶解决方案三:深入浅出,OPHONE开发权威开发指南解决方案四:我连J2ME的基础都没有只有J2EE的基础照样把andriod的环境搭起来了能跑helloworld了这个网上都有教程还有视频找找吧解决方案五:OPHONE开发权威开发指南.Android开发入门与实战.解决方案六:android网站的reference就很清楚!解决方案七:An

【Android开发】范例3-&amp;quot;我同意&amp;quot;游戏条款

实现游戏开始界面中的我同意游戏条款功能:不勾选"我同意"复选框,就不会出现"开始游戏"的按钮,勾选"我同意"复选框,出现"开始游戏"的按钮. 效果图如图: 未点击"我同意"之前 点击"我同意"之后 点击"开始"按钮的瞬间的效果: 具体实现代码: res/layout/main.xml: <LinearLayout xmlns:android="http

Android开发之经典游戏贪吃蛇_Android

前言 这款游戏实现的思路和源码参考了Google自带的Snake的例子,其中修改了一些个人认为还不够完善的地方,加入了一些新的功能,比如屏幕上的方向操作盘,暂停按钮,开始按钮,退出按钮.另外,为了稍微增加些用户体验,除了游戏的主界面,本人自己新增了5个界面,分别是登陆界面,菜单界面,背景音乐设置界面,难度设置界面,还有个关于游戏的介绍界面.个人觉得在新手阶段,参考现成的思路和实现方式是难以避免的.重要的是我们需要有自己的理解,读懂代码之后,需要思考代码背后的实现逻辑,形成自己的思维.这样在下次开

《Android 3D游戏开发技术宝典——OpenGL ES 2.0》——1.3节如何搭建Android开发环境

1.3 如何搭建Android开发环境Android 3D游戏开发技术宝典--OpenGL ES 2.0Eclipse是一款开放源代码.基于Java的可扩展开发平台.其包括一个框架和一组服务,主要通过插件来构建开发环境.而Android的开发工具即为Eclipse的插件,这也减少了开发人员的开发成本.本节主要讲解基于Eclipse的Android开发环境的搭建.模拟器的创建和运行等相关知识. 1.3.1 SDK的安装及环境配置本小节主要介绍Android开发中相关SDK的安装及环境配置,主要包括

Android开发之经典游戏贪吃蛇

前言 这款游戏实现的思路和源码参考了Google自带的Snake的例子,其中修改了一些个人认为还不够完善的地方,加入了一些新的功能,比如屏幕上的方向操作盘,暂停按钮,开始按钮,退出按钮.另外,为了稍微增加些用户体验,除了游戏的主界面,本人自己新增了5个界面,分别是登陆界面,菜单界面,背景音乐设置界面,难度设置界面,还有个关于游戏的介绍界面.个人觉得在新手阶段,参考现成的思路和实现方式是难以避免的.重要的是我们需要有自己的理解,读懂代码之后,需要思考代码背后的实现逻辑,形成自己的思维.这样在下次开

Android开发入门(十二)列表控件 12.3 ListView的总结范例

使用一个例子,来总结一下ListView的基本使用. 1. 新建一个工程:ListViewDemo. 2. main.xml中的代码. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pare

3d-求解Android开发3D游戏的虚拟摇杆怎么做?

问题描述 求解Android开发3D游戏的虚拟摇杆怎么做? RT,如何实现3D手机游戏的虚拟摇杆功能,谁能给讲解一下,或分享个样例供大家学习学习? 解决方案 参考:http://imgtec.eetrend.com/blog/4326

界面跳转-android 开发中界面的跳转

问题描述 android 开发中界面的跳转 我想设置一个监听器直接跳到android模拟器自带的无线和网络设置(Wireless&networks)界面,请大神帮个忙 解决方案 Intent wifiSettingsIntent = new Intent("android.settings.WIFI_SETTINGS"); startActivity(wifiSettingsIntent); 监听可以参考如下:http://blog.sina.com.cn/s/blog_67d

《Android开发基础教程》——6.2节Gallery界面组件——画廊展示

6.2 Gallery界面组件--画廊展示 Android开发基础教程 Gallery组件的展示方式是将图片从左到右的方式排列,如同画廊放置作品一样.但是较为特殊的是Gallery组件支持手指左右拖曳滑动的效果,并且可以选择指定的图片,从界面布局来看是相当灵活而有用的组件. 6.2.1 Gallery语法示例与常用的属性 例如:我们要创建一个Gallery组件,名称为"Gallery01",Gallery组件和边界的距离是5dp,图片间的间隔是2dp,宽度填满整个屏幕,高度根据图片高度