Metro风格的Android界面应用
最近项目中需要一个选择月份查询客户余额的功能,原先的android只能满足查询当月,不可以查询任意月份。当然改起来还是很简单的,服务端增加一个月份参数,客户端传入这个参数即可。闲来无事,月份的选择风格不如做成Metro风格的,现在不是流行扁平化吗,况且我又是微软的忠实粉丝,最近工作没找到,静下心来学学东西,做做实验还是挺好的。
现在把核心布局文件写出来
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" > <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
> <LinearLayout style="@style/menu_item_block_orange"
>
<TextView android:text="一月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/yiyue"
/>
</LinearLayout> <LinearLayout style="@style/menu_item_block_orange"
android:layout_marginLeft="5dp" >
<TextView android:text="二月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/eryue"
/>
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
> <LinearLayout style="@style/menu_item_block_orange"
>
<TextView android:text="三月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/sanyue"
/>
</LinearLayout> <LinearLayout style="@style/menu_item_block_orange"
android:layout_marginLeft="5dp">
<TextView android:text="四月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/siyue"
/>
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
> <LinearLayout style="@style/menu_item_block_orange"
>
<TextView android:text="五月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/wuyue"
/>
</LinearLayout> <LinearLayout style="@style/menu_item_block_orange"
android:layout_marginLeft="5dp">
<TextView android:text="六月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/liuyue"
/>
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
> <LinearLayout style="@style/menu_item_block_orange"
>
<TextView android:text="七月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/qiyue"
/>
</LinearLayout> <LinearLayout style="@style/menu_item_block_orange"
android:layout_marginLeft="5dp">
<TextView android:text="八月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/bayue"
/>
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
> <LinearLayout style="@style/menu_item_block_orange"
>
<TextView android:text="九月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/jiuyue"
/>
</LinearLayout> <LinearLayout style="@style/menu_item_block_orange"
android:layout_marginLeft="5dp">
<TextView android:text="十月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/shiyue"
/>
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
> <LinearLayout style="@style/menu_item_block_orange"
>
<TextView android:text="十一月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/shiyiyue"
/>
</LinearLayout> <LinearLayout style="@style/menu_item_block_orange"
android:layout_marginLeft="5dp">
<TextView android:text="十二月"
android:clickable="true"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/shieryue"
/>
</LinearLayout> </LinearLayout> </LinearLayout> </ScrollView>
每个模块的样式(其实还有很多重复的可以写到样式文件里)
<style name="menu_item_block_orange">
<item name="android:background">@color/blue</item>
<item name="android:layout_width">130dp</item>
<item name="android:layout_height">130dp</item>
</style>
java 文件
package com.example.crazy; import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView; public class MonthActivity extends Activity { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_month);
((TextView)findViewById(R.id.yiyue)).setOnClickListener(l);
((TextView)findViewById(R.id.eryue)).setOnClickListener(l);
((TextView)findViewById(R.id.sanyue)).setOnClickListener(l);
((TextView)findViewById(R.id.siyue)).setOnClickListener(l);
((TextView)findViewById(R.id.wuyue)).setOnClickListener(l);
((TextView)findViewById(R.id.liuyue)).setOnClickListener(l);
((TextView)findViewById(R.id.qiyue)).setOnClickListener(l);
((TextView)findViewById(R.id.bayue)).setOnClickListener(l);
((TextView)findViewById(R.id.jiuyue)).setOnClickListener(l);
((TextView)findViewById(R.id.shiyue)).setOnClickListener(l);
((TextView)findViewById(R.id.shiyiyue)).setOnClickListener(l);
((TextView)findViewById(R.id.shieryue)).setOnClickListener(l);
}
private OnClickListener l=new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(((TextView)v).getId()){
case R.id.yiyue:
gotowebview("1");
break;
case R.id.eryue:
gotowebview("2");
break;
case R.id.sanyue:
gotowebview("3");
break;
case R.id.siyue:
gotowebview("4");
break;
case R.id.wuyue:
gotowebview("5");
break;
case R.id.liuyue:
gotowebview("6");
break;
case R.id.qiyue:
gotowebview("7");
break;
case R.id.bayue:
gotowebview("8");
break;
case R.id.jiuyue:
gotowebview("9");
break;
case R.id.shiyue:
gotowebview("10");
break;
case R.id.shiyiyue:
gotowebview("11");
break;
case R.id.shieryue:
gotowebview("12");
break;
default:break;
}
}
}; private void gotowebview(String month){
Identity.month=month;//Identity是我自定义的存放全局变量的类
Intent it = new Intent(MonthActivity.this, MyAccount.class);
startActivity(it);
}
}
基本上就这些了。其实还可以做得更好一点,比如按下的时候有一个稍微变小的变化。
Metro风格的Android界面应用的更多相关文章
- VC/Wince 实现仿Win8 Metro风格界面2——页面滑动切换(附效果图)
前几天开始写仿Win8 Metro界面文章,部分网友觉得不错,感谢各位的意见.本来今天一直在折腾Android VLC播放器,没时间写.不过明天休息,所以今天就抽时间先写一下. 言归正传,我们都知道W ...
- VC/Wince 实现仿Win8 Metro风格界面1——设计概述和自绘Button(附效果图)
去年用VC做了一个仿Win8 Metro风格的界面,感觉挺有意思,最近打算把实现过程和一些技术原理记录下来. 主要是风格上类似Win8,其实功能上很多借鉴了Android的操作方式.界面只支持两种大小 ...
- 【转载】Android Metro风格的Launcher开发系列第二篇
前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客Android Metro风格的Launcher开发系列第一篇写了如 ...
- [转载] Android Metro风格的Launcher开发系列第一篇
前言:从毕业到现在已经三年多了,回忆一下这三年基本上没有写过博客,总是觉得忙,没时间写,也觉得写博客没什么大用.但是看到很多大牛们都在写博客,分享自己的东西,所以嘛本着向大牛看齐,分享第一,记录第二的 ...
- Android Metro风格的Launcher开发系列第二篇
前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客http://www.cnblogs.com/2010wuhao/p ...
- Android Metro风格的Launcher开发系列第一篇
前言:从毕业到现在已经三年多了,回忆一下这三年基本上没有写过博客,总是觉得忙,没时间写,也觉得写博客没什么大用.但是看到很多大牛们都在写博客,分享自己的东西,所以嘛本着向大牛看齐,分享第一,记录第二的 ...
- Android Metro风格的Launcher开发系列第三篇
前言: 各位小伙伴,又到了每周更新文章了时候了,本来是周日能发出来呢,这不是赶上清明节吗,女王大人发话了,清明节前两天半陪她玩,只留给我周一下午半天时间写博客,哪里有女王哪里就有压迫呀有木有!好了闲话 ...
- METRO风格
METRO风格是指微软在WINDOWS PHONE 7中新加入的界面风格,并且计划将其用于windows8中的开始菜单界面.该界面的特点是简洁高效,每一个METRO图标都没有边框,形状有点像地铁站中的 ...
- Win8 Metro风格的Web桌面HteOS
前言 曾经天天折腾ExtJS,折腾累了.近期这段时间開始用jquery来做一些东西,发现还是蛮有意思的.可是做到最后才发现,原来做好设计真的很重要. 上图就是HteOS项目的截图,眼下正在开发 ...
随机推荐
- WebView加载HTML图片大小自适应与文章自动换行
http://www.brighttj.com/ios/ios-webview-load-html-image-adaptive.html 在很多App中都会使用到webview,尤其是在加载新闻内容 ...
- JavaScript拼接字符串传递多个参数
var ftOpreat = function (value,rows){ var v = rows.Version; var preview = "<a href=\"#\ ...
- 优质IT资源分享社区www.itziyuan.top
你好,我是“优质IT资源分享社区(www.itziyuan.top)”的建设者,同时也是一名普通的IT的热爱者. 首先,我介绍一下网站所收录的教程分类: 基础编程语言: C,C++,C#,Java ...
- hdu 1142(DFS+dijkstra)
#include<iostream> #include<cstdio> #include<cmath> #include<map> #include&l ...
- floyd算法小结
floyd算法是被大家熟知的最短路算法之一,利用动态规划的思想,f[i][j]记录i到j之间的最短距离,时间复杂度为O(n^3),虽然时间复杂度较高,但是由于可以处理其他相似的问题,有着广泛的应用,这 ...
- 第一个jemter测试脚本
通过jmeter代理录制脚本后,会产生大量的无用的请求,尽管在代理中已经过滤了一部分图片或者CSS.JS文件. 手动查看主要的请求:这里主要关注登陆请求,要确定有效的URL请求 删除除/Login.a ...
- House Robber III leetcode 动态规划
https://leetcode.com/submissions/detail/56095603/ 这是一道不错的DP题!自己想了好久没有清晰的思路,参看大神博客!http://siukwan.sin ...
- location
//*******************location对象************************************************************ /*立即打开UR ...
- .NET 4.5+项目迁移.NET Core的问题记录
.NET 4.5+项目迁移.NET Core的问题记录 这几天试着把目前的开发框架迁移到新的.net core平台,中间遇到的问题在这里简单记录一下. 迁移过程遇到的最大的问题IOC容器.我目前使用的 ...
- mysql存储图片问题
1. 借鉴http://blog.chinaunix.net/uid-7374279-id-4255927.html 字段名为blob,有四种类型 TinyBlob(255B).Blob(65k).M ...