Android listview 制作表格样式+由下往上动画弹出效果实现
效果是这样的:点击按下弹出表格的按钮,会由下往上弹出右边的列表,按下返回按钮就由上往下退出界面。
布局文件:
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <Button
android:id="@+id/btnPopup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/bg"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:textColor="@color/white"
android:text="按下弹出表格" /> <LinearLayout
android:id="@+id/ll_popupLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone" > <include layout="@layout/business_list" />
</LinearLayout> </RelativeLayout>
/Demo1/res/layout/business_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" > <TextView
android:id="@+id/tv_business"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/tv_business"
android:textColor="#ff000000"
android:textSize="15sp" /> <TextView
android:id="@+id/tv_business_pay"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:gravity="center"
android:text="@string/tv_business_pay"
android:textColor="#ff000000"
android:textSize="15sp" /> </LinearLayout>
/Demo1/res/layout/business_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_popupLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:text="已开通查分业务列表"
android:textColor="#ff000000"
android:textSize="15sp" /> <FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" > <LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/banner_bg"
android:orientation="horizontal" > <TextView
android:id="@+id/tv_business"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/tv_business"
android:textColor="#ff000000"
android:textSize="15sp" /> <TextView
android:id="@+id/tv_business_pay"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:gravity="center"
android:text="@string/tv_business_pay"
android:textColor="#ff000000"
android:textSize="15sp" />
</LinearLayout> <ListView
android:id="@+id/lv_business"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:background="@drawable/score_list_bg"
android:cacheColorHint="@color/transparent"
android:divider="@drawable/horizontal_line"
android:listSelector="@color/transparent" /> <ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="2dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="2dp"
android:background="@drawable/vertical_line" />
</FrameLayout> <Button
android:id="@+id/btnBack"
android:layout_width="80dp"
android:layout_height="48dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/back_btn_bg"
android:text="返回"
android:textColor="#ffffff" /> </LinearLayout>
动画文件:
/Demo1/res/anim/score_business_query_enter.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate
android:fromYDelta="100%p"
android:duration="600"
/>
</set>
/Demo1/res/anim/score_business_query_exit.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate
android:toYDelta="100%p"
android:duration="600"
/>
</set>
Acitivity
package com.wwj.demo1; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter; public class MainActivity extends Activity { Button btnPopup;
Button btnBack;
ListView listView;
LinearLayout ll_Popup; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); btnPopup = (Button) findViewById(R.id.btnPopup); ll_Popup = (LinearLayout) findViewById(R.id.ll_popupLayout);
// 加载动画
final Animation animation1 = AnimationUtils.loadAnimation(this,
R.anim.score_business_query_enter);
final Animation animation2 = AnimationUtils.loadAnimation(this,
R.anim.score_business_query_exit);
btnPopup.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
ll_Popup.setVisibility(View.VISIBLE); // 显示布局
ll_Popup.startAnimation(animation1); // 开始动画 }
}); btnBack = (Button) findViewById(R.id.btnBack);
btnBack.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
// TODO Auto-generated method stub
ll_Popup.setVisibility(View.GONE); // 取出布局
ll_Popup.startAnimation(animation2); // 开始退出动画
}
}); setListAdapter(); } /**
* 填充列表
*/
private void setListAdapter() { List<Map<String, String>> data = new ArrayList<Map<String, String>>(); // 测试数据
for (int i = 0; i < 10; i++) {
Map<String, String> map = new HashMap<String, String>();
map.put("tv_business", "武汉中考查询测试");
map.put("tv_business_pay", "0元/次");
data.add(map);
} listView = (ListView) findViewById(R.id.lv_business);
SimpleAdapter adapter = new SimpleAdapter(this, data,
R.layout.business_list_item, new String[] { "tv_business",
"tv_business_pay" }, new int[] { R.id.tv_business,
R.id.tv_business_pay });
listView.setAdapter(adapter);
}
}
文章转载于:http://blog.csdn.net/wwj_748/article/details/9854655
Android listview 制作表格样式+由下往上动画弹出效果实现的更多相关文章
- 自定义Dialog,实现由下而上的弹出效果(模仿QQ退出等)
方法: public Dialog createDialog(Context context, View view) { Dialog mSelectPhotoDialog = null; mSele ...
- Android 仿 新闻阅读器 菜单弹出效果(附源码DEMO)
这一系列博文都是:(android高仿系列)今日头条 --新闻阅读器 (一) 开发中碰到问题之后实现的,觉得可能有的开发者用的到或则希望独立成一个小功能DEMO,所以就放出来这么一个DEMO. 原本觉 ...
- Android PopupWindow 仿微信弹出效果
项目中,我须要PopupWindow的时候特别多,这个东西也特别的好使,所以我今天给大家写一款PopupWindow 仿微信弹出效果.这样大家直接拿到项目里就能够用了! 首先让我们先看效果: 那么我首 ...
- Web标准:八、下拉及多级弹出菜单
Web标准:八.下拉及多级弹出菜单 知识点: 1.带下拉子菜单的导航菜单 2.绝对定位和浮动的区别和运用 3.CSS自适应宽度滑动门菜单 1)带下拉子菜单的导航菜单 带下拉子菜单的就是在一级导航下 ...
- firefox浏览器中 bootstrap 静态弹出框中select下拉框不能弹出(解决方案)
问题出现场景1: 在firefox浏览器中在bootstrap弹出的modal静态框中再次弹出一个静态框时 select下拉框不能弹出选项 解决方案:去掉最外层静态框的 tabindex=" ...
- ideal取消按下两次shift弹出搜索框 修改idea,webstrom,phpstrom 快捷键double shift 弹出search everywhere
因为经常需要在中英文之间切换,所以时常使用shift键,一不小心就把这个Searchwhere 对话框调出来了,很是麻烦. 因此痛定思痛, 我决定将这个按两下shift键就弹出搜索框的快捷键禁用了! ...
- 黄聪:TinyMCE 4 增强 添加样式、按钮、字体、下拉菜单和弹出式窗口
我最喜欢 WordPress 3.9 的更新是使用了 TinyMCE 4.0 编辑器.新的 TinyMCE 看起来看起来更整洁(真正匹配WP仪表板),它有一些非常不错的附加功能.我的很多老主题和插件必 ...
- 【android开发】使用PopupWindow实现页面点击顶部弹出下拉菜单
没有太多花样,也没有很复杂的技术,就是简单的PopupWindow的使用,可以实现点击弹出一个自定义的view,view里可以随便设计,常用的可以放一个listview. demo中我只是一个点击展示 ...
- Android开发实战之底部Dialog弹出效果
在Android开发中,有很多情况下我们需要使用到对话框,遗憾的是,安卓自带的对话框样式不能满足我们实际的需要,所以往往需要我们自定义对话框,具体做法:写一个对话框继承自Dialog实现他的一个构造方 ...
随机推荐
- Oracle 删除重复的记录,只保留一条
查询及删除重复记录的SQL语句 1.查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断 select * from 表 where Id in (select Id from 表 g ...
- Android_用户界面概述和数据单位
一.UI界面概述 UI,对于一个应用而言用户界面是非常重要的一部分,是应用的脸,用户对应用第一个印象来自于界面,因此如果没有完美的用户界面,很难留住用户. 好的用户界面会极大提高用户的使用欲望并维护客 ...
- C#_Winfrom下的中英文翻译
Winform下的语言国际化,几行代码轻松实现 最近做了一些关于winform的项目,需要用到winform的语言国际化,在初使化的时候用起来非常方便.可以参考一下: 核心逻辑: 预览效果演示: ...
- hiho_1068_RMQ_st算法
题目 给出一数组A,编号从1到n,然后进行q次查询,每次查询给出一个边界[beg, end],要求给出数组A中范围[beg, end]之内的最小值. 题目链接: RMQ_ST 分析 区间问题使用线段树 ...
- LinuxShell脚本攻略--第一章 小试牛刀
使用 shell 进行数学运算: #!/bin/bash no1=; no2=; let result=no1+no2 echo $result result=$[ $no1 + no2 ] resu ...
- HDELETE
use HDELETE to migration file deletion is good a choice. sample: //STEP0010 EXEC PGM=IKJEFT01 //SYSO ...
- java 集合(Vector)不做重点
Vector: 底层也是维护了一个Object数组,实现与ArrayList是一样的, 但其线程是安全的,效率低.除了比较老的系统,是不会用到的. 笔试题:ArrayList 和 Vector 的区别 ...
- js的with语句使用方法
1)简要说明 with 语句可以方便地用来引用某个特定对象中已有的属性,但是不能用来给对象添加属性.要给对象创建新的属性,必须明确地引用该对象. 2)语法格式 with(object ...
- 关于mvc3.0RadioButtonFor的使用
以前本人没有使用过mvc,近期的话公司要求使用mvc进行开发项目,我不得不学习,我在这里分享下Html.RadioButtonFor的使用,例如 @Html.RadioButtonFor(d => ...
- [Java] 数据库连接管理类
package com.wdcloud.monitoring.common; /** * @Description: TODO * @date: 2015��11��19�� ����10:23:16 ...