android小项目之新闻客户端二

2023-11-05



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

2013年2月15日

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

 

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

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

      

 

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

 

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

    <RelativeLayout
        android:id="@id/titlebar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/image_titlebar_background" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10.0dip"
            android:layout_marginTop="9.0dip"
            android:text="@string/app_name"
            android:textColor="@color/white"
            android:textSize="23.0sp" />

        <Button
            android:id="@id/titlebar_refresh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5.0dip"
            android:layout_marginTop="6.0dip"
            android:background="@drawable/btn_titlebar_refresh_selector" />

        <ProgressBar
            android:id="@id/titlebar_progress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="25.0dip"
            android:layout_height="25.0dip"
            android:layout_alignParentRight="true"
            android:layout_marginRight="14.0dip"
            android:layout_marginTop="10.0dip"
            android:clickable="false"
            android:visibility="gone" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@id/categorybar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="-16dip"
        android:background="@drawable/image_categorybar_background" >

        <Button
            android:id="@id/category_arrow_right"
            android:layout_width="6.0dip"
            android:layout_height="10.0dip"
            android:layout_alignParentRight="true"
            android:layout_marginRight="12dip"
            android:layout_marginTop="17dip"
            android:background="@drawable/image_categorybar_right_arrow" />

        <HorizontalScrollView
            android:id="@id/categorybar_scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dip"
            android:layout_marginTop="3.0dip"
            android:layout_toLeftOf="@+id/category_arrow_right"
            android:scrollbars="none" >

            <LinearLayout
                android:id="@id/category_layout"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_vertical" >
            </LinearLayout>
        </HorizontalScrollView>
    </RelativeLayout>


    <ListView
        android:id="@id/news_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:cacheColorHint="#00000000"
        android:divider="@drawable/image_list_separator_line"
        android:fastScrollEnabled="true"
        android:listSelector="@drawable/news_list_item_selector" />

</LinearLayout>


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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

android小项目之新闻客户端二 的相关文章

  • 算法 - leetcode 292 Nim Game

    算法 leetcode 292 Nim Game 一丶题目 你和你的朋友 两个人一起玩 Nim 游戏 桌子上有一堆石头 每次你们轮流拿掉 1 3 块石头 拿掉最后一块石头的人就是获胜者 你作为先手 你们是聪明人 每一步都是最优解 编写一个函
  • 初级算法(字符串篇):报数

    题目描述 The count and say sequence is the sequence of integers with the first five terms as following 1 11 21 1211 111221 1
  • windows:升级node版本

    目录 1 打开DOS窗口 然后输入 node v 回车 2 输入 where node 查看node安装位置 3 下载你想安装的node版本的msi程序 4 安装步骤3中下载的文件 然后安装位置选择步骤2中的位置 比如步骤2中我的位置是 C
  • 每个人都能制作的简易版QQ音乐(HTML+CSS+JQuery)

    自制系列二它来了 如果在制作过程中有如何问题你都可以私信我 我会答复你的 今天中秋节 首先祝大家中秋节快乐 因为没什么礼物送给大家 所以在这里给大家安利一份简易版QQ音乐的制作 过程很简单 每个人都能学会 下面将是制作步骤了 先建好目录如下
  • 未将对象引用设置到对象的实例--可能出现的问题总结

    一 网络上的一般说法 1 ViewState 对象为Null 2 DateSet 空 3 sql语句或Datebase的原因导致DataReader空 4 声明字符串变量时未赋空值就应用变量 5 未用new初始化对象 6 Session对象
  • python代码使用cython进行加密

    python代码加密 前言 加密的多种方式 Cython加密 步骤 注意 部署 前言 加密的多种方式 发布编译过的pyc文件 缺点 很容易被反编译 PyInstaller 是一个用来将 Python 程序打包成一个独立可执行软件包 支持 W
  • 粉丝提问

    粉丝提问 c语言 如何定义一个和库函数名一样的函数 并在函数中调用该库函数 一个端口号可以同时被两个进程绑定吗 两个线程 两个互斥锁 怎么形成一个死循环 一个例子让你看清线程调度的随机性 问题描述 某个函数fun 1 是在lib内 没法修改
  • R语言:cbind()和rbind()

    可以利用函数cbind 和rbind 把向量和矩阵拼成一个新的矩阵 概略地说 cbind 把矩阵横向合并成一个大矩阵 列方式 而rbind 是纵向合并 行方式 cbind 根据列进行合并 即叠加所有列 m列的矩阵与n列的矩阵cbind 最后
  • ant design of vue 之文件上传组件(腾讯云)封装

    原理 通过调用后台接口获取腾讯云秘钥 然后将秘钥以及文件信息上传到腾讯云 获取文件腾讯云存储信息 最后组件将腾讯云存储信息返回出去 在组件外部调用后台接口将腾讯云信息存到后台 安装cos js sdk v5依赖 npm i cos js s
  • 2021数据治理工具图谱研究报告 附下载

    根据2021年4月发布的 国家数据资源调查报告 2020 显示 2019年我国数据产量总规模为3 9ZB 同比增加29 3 占全球数据总产量 42ZB 的9 3 人均数据产量方面 2019年我国人均数据产量为3TB 数据来源结构方面 数据资
  • 机器学习中的高斯过程

    0 前言 写这篇文章的目的就是为了总结一下最近在学习的高斯过程的一些内容 但是由于我是初学者可能有些地方理解不到位 请大家多多谅解 文末附上了一些数学方面的推导 1 高斯过程定义 高斯过程是在连续域上定义的一种随机过程 可以看成连续域中所有
  • vue中通过js把从接口取到的url中的{}里的参数替换成对应的值

    最近工作中遇到个需求 首先在一个页面中给按钮配置个点击跳转的链接 手动输入需要跳转的url及其需要的参数 后续要在另一个页面中通过接口取到配置的这个url 并替换掉当中的参数 第一次处理这种情况 所以记录一下 前端页面配置url 参数值通过
  • 【YOLO系列】YOLOv5超详细解读(网络详解)

    前言 吼吼 终于来到了YOLOv5啦 首先 一个热知识 YOLOv5没有发表正式论文哦 为什么呢 可能YOLOv5项目的作者Glenn Jocher还在吃帽子吧 hh 目录 前言 一 YOLOv5的网络结构 二 输入端 1 Mosaic数据
  • m118w重置墨粉_富士施乐 Fuji Xerox DocuPrint M118w/M118z重置墨粉页面计数器及重置硒鼓...

    富士施乐M118w的硒鼓和分仓是独立的 前几天M118w就提示墨粉已经不足 于是Pop就看了一下机器 打印了约1200张了 随机器来的原装可能就是这样而已 于是就了解了一下富士施乐M118w如何加粉 如何换硒鼓 以及如何清零重置硒鼓的操作
  • Mac os 10.14装virtualbox 失败的解决方案

    1 Mac 系统装virtualbox 失败如下 2 由于Mac 10 14的安全级别更高 所以导致这个软件安装过程失败 需要一下操作安装就没问题 2 1 开启通用里的允许任何来源 sudo spctl master disable 2 2
  • LeetCode 44 Wildcard Matching (通配符匹配 记忆化搜索 剪枝 推荐)

    Given an input string s and a pattern p implement wildcard pattern matching with support for and Matches any single char
  • Freertos中vTaskDelay()是怎么用的

    1 常见的使用场景 void vLED Task void pvParameters while 1 Heartbeat LED vTaskDelay 1000 portTICK RATE MS 说明 上面这段代码的意思是 led翻转后经过

随机推荐

  • Exception in thread "main" java.lang.NoClassDefFoundError解决

    1 错误描述 Exception in thread main java lang NoClassDefFoundError HelloWorld wrong name org xuwei HelloWorld at java lang C
  • 2018年最好的8款杀毒软件

    如今 网络犯罪和欺骗和攻击电脑的病毒 特洛伊木马和网络钓鱼诈骗导致损失的事件并没有像人们想像的那么频繁发生 这意味着很多人正在使用最强大的安全软件保护自己的电脑 而其一如既往地重要 这就是为什么推出这个2018年全球最佳防病毒软件名单的原因
  • 搭建商城的微服务架构-1

    创建父项目 mall 先创建一个 父项目 mall 再在这个父项目中创建多个子项目 修改pom文件 最终mall的pom文件如下
  • 目标检测算法回顾之Anchor free篇章

    基于anchor free的目标检测方法 一 背景与定义 1 1 anchor based的特征 1 2 anchor的好处 1 3 anchor的局限 1 4 anchor free 与anchor based的区别 二 概述 三 早期探
  • 以太坊2.0 节点搭建:共识端+执行端

    1 配置 本人使用配置 共识端 prysm 版本 3 1 1 执行端 geth 版本 1 10 23 当前使用1 10 25 OS centos7 6 CPU 8核 Memory 16GB RAM Storage 3T SSD Networ
  • 算法梳理boosting\bagging\RF(1)

    LeetCode题目记录 1 集成学习概念 1 1 集成学习分类 1 2 集成学习步骤 2 个体学习器概念 3 boosting bagging 3 1 boosting 3 2 bagging 3 3 二者的区别 4 随机森林的思想 5
  • mlxtend实现简单的Apriori算法(关联算法)

    关联算法有几个重要的概念 下面以官方教程为例 Apple Beer Rice Chicken Apple Beer Rice Apple Beer Apple Bananas Milk Beer Rice Chicken Milk Beer
  • springmvc使用JSR-303进行校验

    下面提供一种springmvc的校验方案 一般没有校验或者手动写validator的话都要写好多代码好多if判断 使用JSR 303规范校验只需要在Pojo字段上加上相应的注解就可以实现校验了 1 依赖的jar包 我直接贴pom了
  • cannot find -l 问题处理

    graalvm打包最后一步 第七步 报错 主要错误简述 It appears as though libstdc a is missing Please install it cannot find lstdc 几个要点 1 l是link的
  • c++模板的概念全新解释

    文章目录 前言 一 模板的概念 强类型的严格性和灵活性 解决冲突的路径 模板的概念 一 1 函数模板 函数模板的定义 函数模板的实例化 函数模板的重载 1 函数模板的重载 2 用普通函数重载函数模板 3 用特定函数重载函数模板 类模板 类模
  • Jsch网络工具包的使用及源码简析

    一 背景 最近 导师安排了些看论文文献并整理论文至文件服务器的工作 在实验的过程中 我们知道常见的上传文件至服务器有以下方式 ftp sftp协议进行上传 ssh连接 并通过scp命令进行上传 通过xftp xshell ftplina等图
  • 【QT】Qt Creator 右击添加库无反应解决方案【转发】

    一 软件版本 Qt 5 9 0 二 问题现象 想向工程添加外部库 但点击添加库无反应 三 解决方案 1 打开 pro 文件 2 在 pro 文件界面内 右击鼠标 选择添加库 3 添加库的 UI 弹出 四 总结 Qt 5 9 0 Creato
  • c#.net常用的小函数参考

    选择自 crabapple2 的 Blog c net常用的小函数和方法集 1 DateTime 数字型 System DateTime currentTime new System DateTime 1 1 取当前年月日时分秒 curre
  • 记录JsonNode文本处理asText()和toString()的差异

    原文地址 https blog csdn net xudc0521 article details 89926158 最近使用JsonNode解析json字符串时 遇到一个与预期不一致的小问题 记录一下 先来看一个Test author x
  • log4j问题解决:log4j:WARN No appenders could be found for logger

    在resources目录下新建log4j properties文件 添加以下代码 log4j rootLogger ERROR log4j appender CONSOLE org apache log4j ConsoleAppender
  • 浙江大学 陈越_浙江大学陈越教授开展“程序设计课程建设”讲座

    12月10日下午 媒体工程学院耿卫东院长邀请了浙江大学陈越教授开展 程序设计课程建设 讲座 学院各课程群负责人 专业主任及其他专业教师共30余人聆听了讲座 并围绕 程序设计课程建设 的主题展开了深入探讨和交流 学院副院长章化冰主持讲座 代表
  • java基础学习 day25(二维数组)

    什么是二维数组 在数组中存放数组 二维数组的应用场景 当我们需要把数据分组管理的时候 就需要用二维数组 静态初始化格式 数据类型 数组名 new 数据类型 元素1 元素2 元素1 元素2 简化格式 数据类型 数组名 元素1 元素2 元素1
  • Java使用JVM工具检测问题

    1 jps 显示运行程序的进程 编码 主类目录信息 public class Demo01 jps 显示进程ID 主类名称 jps v 显示进程ID 主类名称以及详细编码信息 jps l 显示进程ID 主类目录 param args thr
  • 简单理解B树和B+树

    前言 前面我们说了红黑树 他是一种特殊的搜索树 但是由于他只是二叉树 所以这就导致他在大量的数据面前深度过高 同时会造成大量的磁盘空间浪费 所以我们又研究出来了B树和B 树 B树 他是人们早期的一种设计 他打破了二叉树的方式 它可以有多个分
  • android小项目之新闻客户端二

    基于Android的小巫新闻客户端开发 UI设计 主界面 2013年2月15日 由于太多事情要乱 不可能只专注一样东西 因为怕完成不了任务 原本这系列博客就是要在寒假搞定的 没想到拖了那么久 没办法 现在只能有空的时候就回顾一下小巫新闻客户