android footer view

简介: 引用:http://www.eoeandroid.com/code/2011/1208/303.html 导读:其实我们主要实现的就是在页面的地步有一个分类,有了这个我们的用户就会感觉到很友好。          下面详细说说这个页面是怎么做出来的:       1、这个页面最下方可以看到一个TAB页签,分别是“主页”、“提及”等等,这个是一个在底部的TAB分页样式。

引用:http://www.eoeandroid.com/code/2011/1208/303.html

导读:其实我们主要实现的就是在页面的地步有一个分类,有了这个我们的用户就会感觉到很友好。

 

       下面详细说说这个页面是怎么做出来的:

       1、这个页面最下方可以看到一个TAB页签,分别是“主页”、“提及”等等,这个是一个在底部的TAB分页样式。

       2、这个页面就是“主页”这个子页面,是嵌入到上面说的TAB布局中的。由3个部分组成,分别是最上面的状态栏(包含2个按钮,和一个文本区)、中间的列表、最下方的“更多”按钮(当更多按钮点击时,会加载更多数据,并且出现LOADING提示)

 

01 <?xml version="1.0" encoding="utf-8"?>
02 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
03 android:layout_width="fill_parent"
04 android:layout_height="fill_parent">
05 <LinearLayout
06 android:background="#ffffffff"
07 android:layout_width="fill_parent"
08 android:layout_height="fill_parent"
09 android:orientation="vertical" />
10 <include
11 android:id="@+id/head_line"
12 layout="@layout/head_line"
13 android:layout_width="fill_parent"
14 android:layout_height="wrap_content" />
15 <ListView
16 android:cacheColorHint="#00000000"
17 android:id="@id/android:list"
18 android:layout_width="fill_parent"
19 android:fastScrollEnabled="false"
20 android:layout_height="wrap_content"
21 android:paddingTop="45.0dip"
22 android:fadingEdge="none"
23 android:paddingBottom="50.0dip"
24 android:divider="@drawable/list_divider"
25 android:clipToPadding="false" />
26  
27 </FrameLayout>
上面这段代码,就生成了列表,和顶部的状态栏。顶部的状态栏是通过<include>标签引入的
01 <RelativeLayout
02 android:background="@drawable/header"
03 android:layout_width="fill_parent"
04 android:layout_height="wrap_content"
05 xmlns:android="http://schemas.android.com/apk/res/android">
06  
07  
08 <Button
09 android:id="@+id/top_btn_left"
10 android:textColor="@color/button_text_selector"
11 android:background="@drawable/top_refresh_selector"
12 android:layout_width="wrap_content"
13 android:layout_height="wrap_content"
14 android:layout_marginLeft="12.0dip"
15 android:layout_alignParentLeft="true"
16 android:layout_centerVertical="true" />
17  
18  
19 <Button
20 android:id="@+id/top_btn_right"
21 android:textColor="@color/button_text_selector"
22 android:background="@drawable/top_edit_selector"
23 android:layout_width="wrap_content"
24 android:layout_height="wrap_content"
25 android:layout_marginRight="12.0dip"
26 android:layout_alignParentRight="true"
27 android:layout_centerVertical="true" />
28  
29  
30 <TextView
31 android:id="@+id/top_title" android:textSize="22.0sp"
32 android:textColor="@color/head_line_text"
33 android:ellipsize="middle"
34 android:gravity="center_horizontal"
35 android:layout_width="wrap_content"
36 android:layout_height="wrap_content"
37 android:text="@string/user_name"
38 android:singleLine="true"
39 android:layout_toLeftOf="@id/top_btn_right"
40 android:layout_toRightOf="@id/top_btn_left"
41 android:layout_centerInParent="true"
42 android:layout_alignWithParentIfMissing="true" />
43  
44 </RelativeLayout>
是一个最简单的横向排列布局,就不用多介绍了 3、然后是这个FooterView是怎么添加进来的,看代码
01 @Override
02 protected void onCreate(Bundle savedInstanceState) {
03 super.onCreate(savedInstanceState);
04 setContentView(R.layout.home);
05 setUpViews();// 设置视图
06 setUpListeners();// 设置侦听器
07 fillInitData();// 填充初始化数据
08 }
09  
10  
11 /**
12 * 设置视图
13 */
14 private void setUpViews() {
15 listView = getListView();// 得到ListView
16 listFooter = (LinearLayout) LayoutInflater.from(this).inflate(
17 R.layout.list_footer, null);
18 listView.addFooterView(listFooter);// 添加FooterView
19 more = (TextView) findViewById(R.id.more);
20 loading = (LinearLayout) findViewById(R.id.loading);
21 }
通过ListView.addFooterView()方法,来给列表添加一个FooterView,而这个FooterView,也是来自一个layout.xml
01 <?xml version="1.0" encoding="UTF-8"?>
02 <LinearLayout android:layout_width="fill_parent"
03 android:layout_height="wrap_content" android:minHeight="?android:listPreferredItemHeight"
04 xmlns:android="http://schemas.android.com/apk/res/android">
05 <TextView android:textSize="16.0sp" android:textColor="#ff545454"
06 android:gravity="center" android:id="@+id/more"android:layout_width="fill_parent"
07 android:layout_height="fill_parent" android:text="@string/more" />
08 <LinearLayout android:gravity="center"
09 android:layout_gravity="center" android:orientation="horizontal"
10 android:id="@+id/loading" android:layout_width="fill_parent"
11 android:layout_height="fill_parent">
12 <ProgressBar android:layout_gravity="center_vertical"
13 android:id="@+id/footprogress" android:layout_width="wrap_content"
14 android:layout_height="wrap_content"android:indeterminateBehavior="repeat"
15 style="?android:progressBarStyleSmallInverse" />
16 <TextView android:textColor="#ff000000" android:gravity="left|center"
17 android:padding="3.0px" android:layout_width="wrap_content"
18 android:layout_height="wrap_content" android:text="@string/loading" />
19 </LinearLayout>
20  
21 </LinearLayout>
这个FooterView包含一个“更多”的文本框,和一个“读取中”文本框。这里我没弄明白的是,为什么一开始默认只会显示“更多”,读取栏不会显示出来,需要
1 more.setOnClickListener(new OnClickListener() {
2 @Override
3 public void onClick(View v) {
4 more.setVisibility(View.GONE);
5 loading.setVisibility(View.VISIBLE);
6 }
7 });
相关文章
|
8月前
|
Android开发 UED 计算机视觉
Android自定义view之线条等待动画(灵感来源:金铲铲之战)
本文介绍了一款受游戏“金铲铲之战”启发的Android自定义View——线条等待动画的实现过程。通过将布局分为10份,利用`onSizeChanged`测量最小长度,并借助画笔绘制动态线条,实现渐变伸缩效果。动画逻辑通过四个变量控制线条的增长与回退,最终形成流畅的等待动画。代码中详细展示了画笔初始化、线条绘制及动画更新的核心步骤,并提供完整源码供参考。此动画适用于加载场景,提升用户体验。
572 5
Android自定义view之线条等待动画(灵感来源:金铲铲之战)
|
8月前
|
Android开发 开发者
Android设置View是否可用
在Android开发中,有时需要将布局设置为不可点击状态(失去焦点)。常见的解决方法是使用`setOnClickListener(null)`,但本文介绍一种更通用的方式:通过封装`setViewEnabled`方法实现。该方法可递归设置View及其子View的启用状态,支持传入目标View和布尔值(`true`为可用,`false`为禁用)。例如,调用`setViewEnabled(edittext, false)`即可禁用EditText。文章附有源码及示例动图,帮助开发者快速理解与应用。
197 1
|
8月前
|
Android开发
Android自定义view之利用PathEffect实现动态效果
本文介绍如何在Android自定义View中利用`PathEffect`实现动态效果。通过改变偏移量,结合`PathEffect`的子类(如`CornerPathEffect`、`DashPathEffect`、`PathDashPathEffect`等)实现路径绘制的动态变化。文章详细解析了各子类的功能与参数,并通过案例代码展示了如何使用`ComposePathEffect`组合效果,以及通过修改偏移量实现动画。最终效果为一个菱形图案沿路径运动,源码附于文末供参考。
161 0
|
8月前
|
Android开发 开发者
Android自定义view之利用drawArc方法实现动态效果
本文介绍了如何通过Android自定义View实现动态效果,重点使用`drawArc`方法完成圆弧动画。首先通过`onSizeChanged`进行测量,初始化画笔属性,设置圆弧相关参数。核心思路是不断改变圆弧扫过角度`sweepAngle`,并调用`invalidate()`刷新View以实现动态旋转效果。最后附上完整代码与效果图,帮助开发者快速理解并实践这一动画实现方式。
209 0
|
8月前
|
Android开发 数据安全/隐私保护 开发者
Android自定义view之模仿登录界面文本输入框(华为云APP)
本文介绍了一款自定义输入框的实现,包含静态效果、hint值浮动动画及功能扩展。通过组合多个控件完成界面布局,使用TranslateAnimation与AlphaAnimation实现hint文字上下浮动效果,支持密码加密解密显示、去除键盘回车空格输入、光标定位等功能。代码基于Android平台,提供完整源码与attrs配置,方便复用与定制。希望对开发者有所帮助。
156 0
|
8月前
|
XML Java Android开发
Android自定义view之网易云推荐歌单界面
本文详细介绍了如何通过自定义View实现网易云音乐推荐歌单界面的效果。首先,作者自定义了一个圆角图片控件`MellowImageView`,用于绘制圆角矩形图片。接着,通过将布局放入`HorizontalScrollView`中,实现了左右滑动功能,并使用`ViewFlipper`添加图片切换动画效果。文章提供了完整的代码示例,包括XML布局、动画文件和Java代码,最终展示了实现效果。此教程适合想了解自定义View和动画效果的开发者。
398 65
Android自定义view之网易云推荐歌单界面
|
8月前
|
XML 前端开发 Android开发
一篇文章带你走近Android自定义view
这是一篇关于Android自定义View的全面教程,涵盖从基础到进阶的知识点。文章首先讲解了自定义View的必要性及简单实现(如通过三个构造函数解决焦点问题),接着深入探讨Canvas绘图、自定义属性设置、动画实现等内容。还提供了具体案例,如跑马灯、折线图、太极图等。此外,文章详细解析了View绘制流程(measure、layout、draw)和事件分发机制。最后延伸至SurfaceView、GLSurfaceView、SVG动画等高级主题,并附带GitHub案例供实践。适合希望深入理解Android自定义View的开发者学习参考。
754 84
|
8月前
|
Android开发 开发者
Android自定义View之不得不知道的文件attrs.xml(自定义属性)
本文详细介绍了如何通过自定义 `attrs.xml` 文件实现 Android 自定义 View 的属性配置。以一个包含 TextView 和 ImageView 的 DemoView 为例,讲解了如何使用自定义属性动态改变文字内容和控制图片显示隐藏。同时,通过设置布尔值和点击事件,实现了图片状态的切换功能。代码中展示了如何在构造函数中解析自定义属性,并通过方法 `setSetting0n` 和 `setbackeguang` 实现功能逻辑的优化与封装。此示例帮助开发者更好地理解自定义 View 的开发流程与 attrs.xml 的实际应用。
243 2
Android自定义View之不得不知道的文件attrs.xml(自定义属性)
|
8月前
|
前端开发 Android开发 UED
讲讲Android为自定义view提供的SurfaceView
本文详细介绍了Android中自定义View时使用SurfaceView的必要性和实现方式。首先分析了在复杂绘制逻辑和高频界面更新场景下,传统View可能引发卡顿的问题,进而引出SurfaceView作为解决方案。文章通过Android官方Demo展示了SurfaceView的基本用法,包括实现`SurfaceHolder.Callback2`接口、与Activity生命周期绑定、子线程中使用`lockCanvas()`和`unlockCanvasAndPost()`方法完成绘图操作。
252 3
|
8月前
|
Android开发 开发者
Android自定义view之围棋动画(化繁为简)
本文介绍了Android自定义View的动画实现,通过两个案例拓展动态效果。第一个案例基于`drawArc`方法实现单次动画,借助布尔值控制动画流程。第二个案例以围棋动画为例,从简单的小球直线运动到双向变速运动,最终实现循环动画效果。代码结构清晰,逻辑简明,展示了如何化繁为简实现复杂动画,帮助读者拓展动态效果设计思路。文末提供完整源码,适合初学者和进阶开发者学习参考。
161 0
Android自定义view之围棋动画(化繁为简)