多功能记事本开发之路——01 界面布局篇
来源:互联网 发布:linux shell 设置变量 编辑:程序博客网 时间:2024/04/30 13:10
Android 自带的记事本功能有限对于我这个处女座的人来说这无疑是一种精神上的摧残。那我还是自己写一个记事本软件好了。这一次我不想做单纯的生成文本的功能,我想再次基础上加上一些扩展功能。具体功能整个布局的图片都可以看的到。 今天先来完成下界面布局吧。Android 的布局个人觉得还是很麻烦(至少比起JAVASE这是真的) 后期用到的数据库无非就是SQLite算是比较简单,但我尽力把这个APP做的人性化一些小细节觉得心情嘛。先来看一下整个软件的布局。
主布局:activity_main.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/navigationbar_bg" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello world" android:textColor="#000000" /></RelativeLayout>
这个时候来重写一个title来替换掉原有的那个蹉B
title_add .xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/iv_icon" android:layout_width="35dp" android:layout_height="35dp" android:src="@drawable/icon" android:layout_margin="5dp" android:layout_alignParentLeft="true" /> <TextView android:layout_width="wrap_content" android:layout_height="35dp" android:text="记事本" android:layout_margin="5dp" android:textSize="20dp" android:gravity="center_vertical" android:layout_toRightOf="@id/iv_icon" /> <Button android:id="@+id/bt_add" android:layout_height="35dp" android:layout_width="35dp" android:background="@drawable/navigationbar_add" android:layout_toLeftOf="@+id/bt_setting" android:layout_margin="5dp" /> <Button android:id="@+id/bt_setting" android:layout_height="35dp" android:layout_width="35dp" android:background="@drawable/navigationbar_setting" android:layout_alignParentRight="true" android:layout_margin="5dp" /></RelativeLayout>
item_button.xml这个是上述GridView中每一项布局文件:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:id="@+id/item_image" android:layout_height="35dp" android:layout_width="35dp" android:layout_margin="5dp" /> </RelativeLayout>
然后替换掉Android自带的标题栏 (顺序不可错)
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.activity_main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_main);
title_add2.xml 同样是添加记事界面的标题栏 只不过布局有所变化,在第二个界面中用到的是返回与确定 :
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="45dp" android:background="@drawable/navigationbar_bg"> <Button android:id="@+id/bt_back" android:layout_width="35dp" android:layout_height="35dp" android:background="@drawable/navigationbar_backup" android:layout_margin="5dp" android:layout_alignParentLeft="true" /> <TextView android:layout_width="wrap_content" android:layout_height="35dp" android:text="新增记事" android:layout_margin="5dp" android:textSize="20dp" android:gravity="center_vertical" android:layout_centerHorizontal="true" /> <Button android:id="@+id/bt_save" android:layout_height="35dp" android:layout_width="35dp" android:background="@drawable/navigationbar_save" android:layout_alignParentRight="true" android:layout_margin="5dp" /> </RelativeLayout>
第二个界面一如既往的使用了一点也不Simple的SimpleAdapter,主要代码为:
不好意思,居然忘记用for循环,这把我敲的 (嘿嘿)
ArrayList<HashMap<String,Object>> imagelist = new ArrayList<HashMap<String,Object>>();HashMap<String,Object> map1 = new HashMap<String,Object>(); map1.put("image", R.drawable.tabbar_handwrite); imagelist.add(map1); HashMap<String,Object> map2 = new HashMap<String,Object>(); map2.put("image", R.drawable.tabbar_paint); imagelist.add(map2); HashMap<String,Object> map3 = new HashMap<String,Object>(); map3.put("image", R.drawable.tabbar_microphone); imagelist.add(map3); HashMap<String,Object> map4 = new HashMap<String,Object>(); map4.put("image", R.drawable.tabbar_photo); imagelist.add(map4); HashMap<String,Object> map5 = new HashMap<String,Object>(); map5.put("image", R.drawable.tabbar_camera); imagelist.add(map5); HashMap<String,Object> map6 = new HashMap<String,Object>(); map6.put("image", R.drawable.tabbar_appendix); imagelist.add(map6); SimpleAdapter simpleAdapter = new SimpleAdapter(this, imagelist, R.layout.item_button, new String[] {"image"}, new int[]{R.id.item_image}); // 设置GridView的适配器为新建的simpleAdapter gridView.setAdapter(simpleAdapter);}
0 0
- 多功能记事本开发之路——01 界面布局篇
- 多功能记事本开发之路——02 实现事件监听器
- JAVA进阶5.15——记事本界面
- Unity——UGUI之界面布局
- iOS开发之UI控件——UIPickerView实现点菜系统界面布局
- Android开发之应用界面布局Layout
- android <初级篇> 界面布局<一> ——菜鸟的学习之路
- 【Android开发学习23】界面布局之线性布局LinearLayout
- 【Android开发学习25】界面布局之相对布局RelativeLayout
- ScriptCase开发平台介绍(三)——界面布局
- android开发——界面五大布局
- 安卓开发——安卓界面布局笔记
- java图形化界面编程之记事本
- GUI界面编程——记事本初级实现
- 记事本界面
- IO编程——记事本开发
- Java图形界面开发—简易记事本
- Android记事本开发之界面设计
- 2014-10-16 学习日志
- Week10-乘法表
- Metasploit backdoor
- [代码阅读]数据库源代码阅读练习
- ios 发布应用到appStore
- 多功能记事本开发之路——01 界面布局篇
- 文章里面有好的书籍
- QT窗体间传值总结
- LDAP是什么?OLAP是什么?OLTP是什么?
- nyoj325zb的生日+邮票分你一半
- iOS 获取手机的型号,系统版本,软件名称,软件版本
- STL源码剖析:空间配置器
- 【有源汇有上下界最大流】ZOJ-3229 Shoot the Bullet
- C++的头文件和实现文件分别写什么