一个android文本比对app的实现(二)--界面
来源:互联网 发布:15赛季nba季后赛数据 编辑:程序博客网 时间:2024/05/21 09:17
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">继上一篇博文大致介绍了这一简单但有点用处的app后(详情:</span><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">http://download.csdn.net/detail/tyler_download/9273255),本篇对该app的界面实现做一些说明。谷歌对android app 的界面开发提供了精巧的设计,其界面设计的布局技术(layout), 运用了类似于设计模式的composite pattern, 具体来说,就像俄罗斯娃娃,外面一个大娃娃可以套一个小娃娃。android 的layout 里面可以再嵌入其他layout, 层层递进,进而形成变化多样而又非常灵活的界面布局。</span>
本app 的启动界面设计比较简单,最高层的layout是一个 table layout, table 分两行,第一行和第二行高度比是九比一, 第一行里面潜入了一个linear layout, 这个linear layout 又被平均分成两部分,分别存放两个textview 控件,第二行则用于存放底部按钮栏,整体布局文件内容如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".TwoHouseTansActivity" > <TableLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.88" android:id="@+id/top" > <TableRow android:id="@+id/tableRow1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.5" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/tvbar" /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.5" > <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/tvbar1" /> </TableRow> </TableLayout> <include layout="@layout/bottom_tab_layout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.12"> </include></LinearLayout>
值得注意的是, 第二行table row 使用关键字include 引入了新的布局文件,这样可以避免一个布局文件变得过于庞大和复杂。底层工具栏是一个比较实用的组件,我也是从别的朋友那借鉴过来的,该组件不是我原创,由于其易用性,在这里解析一下底层工具栏的设计思路,或许对有需要的朋友会有些帮助。我们看看底层工具栏的布局文件内容:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bottom_bar" android:orientation="horizontal" > <LinearLayout android:id="@+id/id_tab_prev" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <!-- android:clickable="false" 是为了防止ImageButton截取了触摸事件 ,这里事件要给它的上一级linearlayout--> <ImageButton android:id="@+id/go_down_img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:clickable="false" android:src="@drawable/go_down" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一处" /> </LinearLayout> <LinearLayout android:id="@+id/id_tab_address" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/go_up_img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:clickable="false" android:src="@drawable/go_up" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="通讯录" /> </LinearLayout> <LinearLayout android:id="@+id/id_tab_frd" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/id_tab_frd_img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:clickable="false" android:src="@drawable/tab_find_frd_normal" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="发现" /> </LinearLayout> <LinearLayout android:id="@+id/id_tab_settings" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/id_tab_settings_img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:clickable="false" android:src="@drawable/tab_settings_normal" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我" /> </LinearLayout></LinearLayout>
底部工具栏在整体上,使用了一个水平方向的线性布局,然后又将水平空间平均分成四小块,在每一小块里,又嵌入一个竖直方向的线性布局。在这个竖直方向的布局小方块的顶部,我们放置了一个ImangeButton 控件,在按钮控件的下方,放置了一个textview, 用来做按钮的标题,这一布局最终形成的效果如下:
这里面有一个bug, 就是前两个上下箭头按钮,由于图片过大,从而盖住了下方的textview, 找时间我要改掉,本着互联网的迭代精神,暂且把他放上去吧。我的界面设计虽然简单,但管中窥豹,基本上展示了android界面设计的技术特点,就是通过件套布局的方式,循环递归的设计出复杂多变的操控界面。
0 0
- 一个android文本比对app的实现(二)--界面
- 一个android文本比对app的实现(四)--Hirschberg文本比对算法
- 一个android 文本比对App的实现(一)
- 一个android文本比对APP的实现(三)-设计模式在文件选择模块中的运用
- 用集算器实现文本比对
- 用集算器实现文本比对
- Android客户端之“微服私访”App的系统学习(二)TextInputLayout实现登录界面和LitePal初始化本地数据库
- [Android通信]基于socket的聊天app(二):实现聊天界面
- Android上实现一个简单的天气预报APP(六) 更新界面数据
- Android上实现一个简单的天气预报APP(七) 切换到新的界面(选择城市界面)
- 文本的全文内容比对
- 一个嵌入式web服务器项目,实现通过手机Android App实现对嵌入式设备的控制
- 从零开始打造一个新闻订阅APP之Android篇(一、实现仿微信主界面效果)
- 从零开始打造一个新闻订阅APP之Android篇(四、实现仿微信发图界面)
- 【Android界面实现】ZListView,一个最强大的刷新、加载、滑动删除的ListView控件(二)
- 【Android界面实现】ZListView,一个最强大的刷新、加载、滑动删除的ListView控件(二)
- android app引导界面实现
- LSH(局部敏感哈希算法)实现文本的相似性比对
- C#String.Format大全
- Write your own Android Authenticator (Account Manager)
- Android中常用的位图操作(View与Bitmap转化、圆角、灰化、提取Alpha、旋转、倒影、剪切……)
- unable to resolve virtual method 错误
- SAP 使用ST05跟踪方法!
- 一个android文本比对app的实现(二)--界面
- 关于ojdbc6与class12那些事
- matlab并行编程SPMD
- org.apache.http.Header这个类找不到的情况
- C# 中的委托和事件 观察者模式
- VS2010 ADO远程访问sql server 2008方法总结
- 查看远程Redis服务器的版本
- Python特殊语法:filter、map、reduce、lambda
- 玩转git之webhook应用初探