基于Android的小巫新闻客户端开发--UI设计(主界面)

2013年2月15日

由于太多事情要乱,不可能只专注一样东西,因为怕完成不了任务。原本这系列博客就是要在寒假搞定的,没想到拖了那么久,没办法。现在只能有空的时候就回顾一下小巫新闻客户端,在复习一下这样子了。大概会在10篇以内把整个客户端开发给写完,不可能面面俱到的了,只是把核心的东西,稍微总结一下,回顾一下。

关于这个新闻客户端的开发,小巫是从设计界面开始的,简单的来说就是搭建框架,把整体的框架建好了,剩下的就是业务逻辑的实现了。那好,这篇用来介绍主界面的设计过程。

首先看看最初想实现的效果和最终实现的效果:

光看效果图,我们都大致能想到用什么布局来实现上面的效果。光用语言来描述,总是欠缺想象力的,还是先帖代码,再介绍。

[html] view plain copy print ?
  1. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:id="@id/main_layout"
  4. android:layout_width="match_parent"
  5. android:layout_height="wrap_content"
  6. android:background="@drawable/main_background"
  7. android:orientation="vertical">
  8. <RelativeLayout
  9. android:id="@id/titlebar_layout"
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:background="@drawable/image_titlebar_background">
  13. <TextView
  14. android:layout_width="wrap_content"
  15. android:layout_height="wrap_content"
  16. android:layout_marginLeft="10.0dip"
  17. android:layout_marginTop="9.0dip"
  18. android:text="@string/app_name"
  19. android:textColor="@color/white"
  20. android:textSize="23.0sp"/>
  21. <Button
  22. android:id="@id/titlebar_refresh"
  23. android:layout_width="wrap_content"
  24. android:layout_height="wrap_content"
  25. android:layout_alignParentRight="true"
  26. android:layout_marginRight="5.0dip"
  27. android:layout_marginTop="6.0dip"
  28. android:background="@drawable/btn_titlebar_refresh_selector"/>
  29. <ProgressBar
  30. android:id="@id/titlebar_progress"
  31. style="?android:attr/progressBarStyleLarge"
  32. android:layout_width="25.0dip"
  33. android:layout_height="25.0dip"
  34. android:layout_alignParentRight="true"
  35. android:layout_marginRight="14.0dip"
  36. android:layout_marginTop="10.0dip"
  37. android:clickable="false"
  38. android:visibility="gone"/>
  39. </RelativeLayout>
  40. <RelativeLayout
  41. android:id="@id/categorybar_layout"
  42. android:layout_width="match_parent"
  43. android:layout_height="wrap_content"
  44. android:layout_marginTop="-16dip"
  45. android:background="@drawable/image_categorybar_background">
  46. <Button
  47. android:id="@id/category_arrow_right"
  48. android:layout_width="6.0dip"
  49. android:layout_height="10.0dip"
  50. android:layout_alignParentRight="true"
  51. android:layout_marginRight="12dip"
  52. android:layout_marginTop="17dip"
  53. android:background="@drawable/image_categorybar_right_arrow"/>
  54. <HorizontalScrollView
  55. android:id="@id/categorybar_scrollView"
  56. android:layout_width="match_parent"
  57. android:layout_height="wrap_content"
  58. android:layout_marginLeft="8dip"
  59. android:layout_marginTop="3.0dip"
  60. android:layout_toLeftOf="@+id/category_arrow_right"
  61. android:scrollbars="none">
  62. <LinearLayout
  63. android:id="@id/category_layout"
  64. android:layout_width="wrap_content"
  65. android:layout_height="match_parent"
  66. android:gravity="center_vertical">
  67. </LinearLayout>
  68. </HorizontalScrollView>
  69. </RelativeLayout>
  70. <ListView
  71. android:id="@id/news_list"
  72. android:layout_width="match_parent"
  73. android:layout_height="match_parent"
  74. android:cacheColorHint="#00000000"
  75. android:divider="@drawable/image_list_separator_line"
  76. android:fastScrollEnabled="true"
  77. android:listSelector="@drawable/news_list_item_selector"/>
  78. </LinearLayout>


以上代码就是该效果图的xml代码,可以知道最外层的布局是用线性布局的(LinearLayout),其中嵌套了两个相对布局(RelativeLayout),最后是一个ListView组件;整个界面的布局设计就这么简单,第一个RelativeLayout是标题栏的布局,其中有一个TextView和一个刷新按钮;第二个RelativeLayout是分类栏的布局,这个稍微复杂一点,有一个Button组件,还有HorizontalScrollView.具体代码请读者自行查看。其中还有一些细节,比如说背景,还有一下效果。需要读者自己去体会才能了解清楚。在这里也无法说得太明白。


原:http://blog.csdn.net/wwj_748/article/details/8581906


更多相关文章

  1. Android(安卓)仿 窗帘效果 和 登录界面拖动效果 (Scroller类的应
  2. 使用HttpURLConnection实现在android客户端和服务器之间传递对象
  3. Android实现推送消息的解决方案
  4. Android学习笔记之界面控件大小dip及布局管理器嵌套使用
  5. Android(安卓)TV (三)(创建电视页面布局)
  6. Android(安卓)Studio安卓学习笔记(三)Android用户界面的设计布局
  7. Android(安卓)Studio基础之主界面及使用(三)-学习篇
  8. Android(安卓)模仿Path 的左右拉动菜单效果
  9. Android简易音乐播放器之界面实现(第一篇)

随机推荐

  1. 详解数据库连接的URL的写法及总结
  2. mysql5.7.19 winx64安装配置方法图文教程
  3. MySql超长自动截断实例详解
  4. mysql 5.7.15 安装配置方法图文教程(wind
  5. Mysql 5.6.37 winx64安装双版本mysql笔记
  6. centos6.5下mysql 5.7.19 安装配置方法
  7. mysql5.7.19 安装配置方法图文教程(win10
  8. mysql5.7.19 winx64解压缩版安装配置教程
  9. MySql安装与卸载的详细教程
  10. mysql连接查询(左连接,右连接,内连接)