Android新闻客户端开发3--显示新闻详细内容UI设计
基于Android小巫新闻客户端开发---显示新闻详细内容UI设计
2013年2月27日,天气潮湿!!!
距上一次写的主界面业务逻辑实现,已经过来11天,小巫觉得拖得太久了,所以决定尽量把所有的内容介绍完,好完成这个任务,因为小巫已经开学了,将会有更加重的任务等着。在发表前面几章博客之前,小巫已经把项目源代码共享了,这里稍微提一下关于这个项目的部署的问题吧,因为可能在你们的机器上难免会出点问题,小巫之前把整个软件测试调通也花了不少时间,主要是服务端的问题,跟数据库的连接可能会出错,因为在我的机器上安装的MySQL所建立的用户和密码可能不一样,需要在服务端,修改一下连接数据库的配置文件。
这里可能要修改的地方有:端口号、用户名、密码,这需要根据各位童鞋自己配置MySQL的时候为准。
还有一点,是关于编码的问题:这个web项目所使用的编码格式是utf-8,因为MyEclipse默认的编码格式是GBK,这就需要到【Window】->【Preference】->【General】->【Workspace】然后修改encoding为utf-8,这样程序就不会出现乱码问题了。这要MyEclipse配好服务器,把项目部署到Tomcat中,我想应该没问题了。如果出现问题的话,小巫也无法一下子回答,那就要靠你们自己寻找原因吧。
那好回到博客正题!!!---显示新闻详细内容UI界面的设计
效果如下:
因为在动手开发小巫新闻客户端是打算为小巫所在的学校开发一个新闻客户端,专门用来显示我们学校的新闻,后来发现实现起来意义不大,后来改了名字,以小巫命名这个新闻客户端,所以这里显示为华广新闻,希望不要介意。
要实现整个界面效果需要3个xml文件:
1.newsdetail_layout.xml,
2.newsbody_layout.xml,
3.news_reply_frame_layout.xml
具体实现需要看看代码:
/newsdetail_layout.xml
- <?xml version="1.0" encoding="utf-8"?>
- <!-- 最外层界面布局是RelativeLayout -->
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@id/newsdetail_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/main_background"
- >
- <!--
- 标题栏用RelativeLayout,包含一个向前查看按钮、向后查看按钮
- 一个TextView, 一个跟帖按钮
- -->
- <RelativeLayout
- android:id="@id/newsdetail_titlebar_layout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/image_titlebar_background"
- >
- <Button
- android:id="@id/newsdetail_titlebar_previous"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_marginTop="7.0dip"
- android:layout_marginLeft="5.0dip"
- android:background="@drawable/newsdetail_titlebar_btn_privious_selector"
- />
- <Button
- android:id="@id/newsdetail_titlebar_next"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_marginRight="5.0dip"
- android:layout_marginTop="7.0dip"
- android:background="@drawable/newsdetail_titlebar_btn_next_selector"
- />
- <Button
- android:id="@id/newsdetail_titlebar_comments"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_marginRight="50.0dip"
- android:layout_marginTop="10.0dip"
- android:text="0跟帖"
- android:textColor="@color/white"
- android:background="@drawable/newsdetail_titlebar_btn_comments_selector" />
- <TextView
- android:id="@id/newsdetail_titlebar_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@id/newsdetail_titlebar_previous"
- android:layout_marginLeft="20dip"
- android:layout_toRightOf="@id/newsdetail_titlebar_previous"
- android:text="校内"
- android:textColor="@color/white"
- android:textSize="18.0sp" />
- </RelativeLayout>
- <!-- 用于翻页的的ViewFlipper -->
- <ViewFlipper
- android:id="@id/news_body_flipper"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@id/newsdetail_titlebar_layout"
- android:layout_marginBottom="40.0dip" >
- </ViewFlipper>
- <include
- android:id="@id/comment_reply_frame"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- layout="@layout/news_reply_frame_layout" />
- </RelativeLayout>
这个布局文件用到了<include>标签,它的作用是将另一个布局文件包含进来,这样可以实现代码的复用,因为下面的回复栏,在查看评论的界面也需要用到。这是这段代码需要注意的地方,其他的就不多说了。
/newsbody_layout.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:wwj="http://schemas.android.com/apk/res/com.xiaowu.news"
- android:id="@id/news_body_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <!-- android:fadingEdge="none"的作用解析
- 设置拉滚动条时 ,边框渐变的放向。none(边框颜色不变)
- ,horizontal(水平方向颜色变淡),vertical(垂直方向颜色变淡) -->
- <ScrollView
- android:id="@id/news_body_scrollview"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#FFE7E7E7"
- android:fadingEdge="none"
- >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- >
- <TextView
- android:id="@id/news_body_title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="12.0dip"
- android:layout_marginTop="12.0dip"
- android:textColor="#FF272727"
- android:textSize="18.0sp"
- android:textStyle="bold"
- />
- <TextView
- android:id="@id/news_body_ptime_source"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="12.0dip"
- android:layout_marginRight="12.0dip"
- android:layout_marginTop="9.0dip"
- android:textColor="#FF888888"
- android:textSize="12.0sp"
- />
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="8.0dip"
- android:src="@drawable/image_widget_hot_list_separator_line"
- />
- <ProgressBar
- android:id="@id/news_body_detail_loding"
- style="?android:attr/progressBarStyleLarge"
- android:layout_width="16.0dip"
- android:layout_height="16.0dip"
- android:layout_marginLeft="152.0dip"
- android:layout_marginTop="10.0dip"
- android:clickable="false"
- android:visibility="gone"
- />
- </LinearLayout>
- <com.xiaowu.news.ConstomTextView
- android:id="@id/news_body_details"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5.0dip"
- android:textColor="#ff000000"
- wwj:image_width="200dip"
- wwj:image_height="52dip"/>
- </LinearLayout>
- </ScrollView>
- </LinearLayout>
这段代码只有一个需要特别注意的,因为这是在这个项目后期才添加上的内容:自定义TextView和异步更新加载图片,这跟之前有所差别,因为这里包含了一个自定义的组件,ConstomTextView,上面代码已经写的很清楚了。如果有点不明白的话,来看小巫之前所发表的一篇文章,希望有所帮助:http://blog.csdn.net/wwj_748/article/details/8195975
/news_reply_frame_layout.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@id/news_reply_layout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:background="@drawable/image_toolbar_background"
- android:orientation="horizontal"
- android:visibility="visible"
- >
- <LinearLayout
- android:id="@id/news_reply_edit_layout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:orientation="horizontal"
- android:visibility="gone"
- >
- <EditText
- android:id="@id/news_reply_edittext"
- android:layout_width="260.0dip"
- android:layout_height="wrap_content"
- android:layout_marginTop="2.0dip"
- android:hint="@string/et_reply"
- android:maxLength="500" />
- <Button
- android:id="@id/news_reply_post"
- android:layout_width="58.0dip"
- android:layout_height="42.0dip"
- android:text="@string/reply_post"
- android:textColor="@color/white"
- android:background="@drawable/btn_send_reply_selector"/>
- </LinearLayout>
- <LinearLayout
- android:id="@id/news_reply_img_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5.0dip"
- android:layout_marginTop="3.0dip"
- android:gravity="center"
- android:orientation="horizontal"
- android:visibility="visible">
- <ImageButton
- android:id="@id/news_reply_img_btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20.0dip"
- android:layout_weight="1.60"
- android:background="#00000000"
- android:src="@drawable/news_reply_img_btn_background" />
- <ImageButton
- android:id="@id/news_share_btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10.0dip"
- android:background="#00000000"
- android:src="@drawable/newsdetail_toolbar_btn_share_selector" />
- <ImageButton
- android:id="@id/news_favorites_btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10.0dip"
- android:background="#00000000"
- android:src="@drawable/newsdetail_toolbar_favorites_selector" />
- </LinearLayout>
- </LinearLayout>
这个布局,没有什么难点,在这里小巫也不过多浪费口舌。
总之一句,试过就知道了,如果觉得整个项目有难度,并不适合初学者,各位童鞋可以择重学习。
原:http://blog.csdn.net/wwj_748/article/details/8619107
Android新闻客户端开发3--显示新闻详细内容UI设计相关推荐
- 基于Android小巫新闻客户端开发---显示新闻详细内容UI设计
基于Android小巫新闻客户端开发---显示新闻详细内容UI设计 2013年2月27日,天气潮湿!!! 距上一次写的主界面业务逻辑实现,已经过来11天,小巫觉得拖得太久了,所以决定尽量把所有的内容介 ...
- Android应用开发-小巫CSDN博客客户端之显示博文详细内容
Android应用开发-小巫CSDN博客客户端之显示博文详细内容 上篇博文给大家介绍的是如何嵌入有米广告并且获取收益,本篇博客打算讲讲关于如何在一个ListView里显示博文的详细信息,这个可能是童鞋 ...
- 基于Android的小巫新闻客户端开发--UI设计(主界面)
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 基于An ...
- 开篇--基于Android的小巫新闻客户端开发
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 开篇-- ...
- 基于安卓的新闻客户端开发
研究背景 当前市面上移动新闻客户端,包括网易移动新闻客户端,搜狐移动新闻客户端,凤凰移动新闻客户端等.这些客户端界面绚丽,版面较多,操作过程较为复杂.为简化流程,操作简单,方便用户使用和下载.所以, ...
- Android简易新闻客户端自动升级 简易新闻(二十)
Android简易新闻客户端自动升级 简易新闻(二十) 关于 说明 第一步,添加引用 第二步,注册蒲公英账号 第三步,添加AndroidManifest.xml配置 初始化 最后一步 打包上传 关于 ...
- Android:Socket客户端开发,Android 的Socket客户端优化,Android非UI线程修改控件程序崩溃的问题
一.Android:Socket客户端开发 创建一个工程 我们要做的是按下按键之后,去往服务器 (服务器) 或者我们自己写的服务器 ,给他发送一些预定好的东西 然后打开操作界面 然后修改一下 你要发送 ...
- 浅谈android手机客户端开发
广州手机app客户端开发公司[启汇网络]企业开始注重Android手机客户端开发,源于android手机市场的庞大. 从android手机数量上看,三星无疑是推出 Android 移动设备最多的公司, ...
- 指令汇B新闻客户端开发(四) 自动轮播条
在这个新闻客户端,我们可以看到有一个轮播页面,在这个项目中,用Handler和一个定时器来做更容易一些, 我们定义一个Handler: private Handler mHandler; 定时器的代码 ...
最新文章
- 快学Scala 第二课 (apply, if表达式,循环,函数的带名参数,可变长参数,异常)...
- Unitest框架的使用(一)准备工作,接口定义和Unittest方法
- 【求救】如何调用Windows系统自带的“选择用户”、“选择组”的对话框?
- Julia之初体验(一)下载与安装
- 斐讯E1刷K2版老毛子Padavan,完美实现中继教程
- 国外服务器网站打开速度慢,使用国外服务器时访问为什么很慢?
- Connection接口
- 外贸企业oa移动办公管理系统
- Msbuild的工具集版本
- 浅析能源物联网技术在校园能耗监测系统中的应用与研究
- 数据库常见面试题 —— 7.事务的四种特性
- JT/T1078-车辆终端模拟器
- 输入一行字符统计英文字母,空格,数字和其他字符的个数
- 使用while 循环1234568910
- html js涨幅率怎么计算,JS加速线指标的计算公式及买卖分析
- Qt控件样式 Style Sheet Demo
- 不要再这么傻,OK?
- 微信小程序——按时间逆序排序
- 超分辨latex论文写作图片排版
- 【达梦数据库】VMware虚拟机 + CentOS7环境配置 + DM8 数据库安装流程
热门文章
- fMRI基础理论知识学习
- oracle drop column 多个,3000W记录,alter table drop column很慢
- GaussDB200与postgresql相关性
- 汽车为什么会“跑”: 图解汽车构造与原理 陈新亚编著
- android canvas光晕绘制_android用canvas绘制两种波纹效果
- 字符设备编程(四)之可爱的 misc
- bugku域名解析记录
- Android---flipper实现图片轮播
- 【Python运行报错】yaml.parser.ParserError: while parsing a block collection
- python实现两个excel数据匹配,最终写入新的excel文件