自定义控件:飞入飞出的效果
2016-04-08 16:05
204 查看
效果图:
![](https://img-blog.csdn.net/20160408160320939?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
用到4个类(copy)
1 布局:
* 步骤:
* 准备:复制4个类
* 1 布局+获取StellarMap对象
* 2 设置adapter
* 3 设置StellarMap参数
* 1 布局+获取StellarMap对象
* 2 设置adapter
3 设置StellarMap参数
若想第一页就显示数据,那么方法setGroup(0, true);必须放在setAdapter(adapter)后面,其他方法顺序无所谓;
源码:http://download.csdn.net/detail/ss1168805219/9485126
用到4个类(copy)
1 布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <com.baidu.stellarmap.lib.StellarMap android:id="@+id/stleeMap" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
* 步骤:
* 准备:复制4个类
* 1 布局+获取StellarMap对象
* 2 设置adapter
* 3 设置StellarMap参数
* 1 布局+获取StellarMap对象
//1获取StellarMap对象 stellarMap = (StellarMap) findViewById(R.id.stleeMap);
* 2 设置adapter
//2 设置adapter MyAdapter adapter = new MyAdapter(); stellarMap.setAdapter(adapter);
class MyAdapter implements Adapter {// 注意:Adapter是stellMap包下的,是interface // 共多少组数据 @Override public int getGroupCount() { return 3; } // 每一组有多少条数据 @Override public int getCount(int group) { return 11; } @Override public View getView(int group, int position, View convertView) { TextView tv = new TextView(context); tv.setText("item" + position); // 1 设置字体大小 Random random = new Random(); int textSize = random.nextInt(8) + 15; tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); // 2 设置字体颜色 int red = random.nextInt(150) + 50; int green = random.nextInt(150) + 50; int blue = random.nextInt(150) + 50; int textColor = Color.rgb(red, green, blue); tv.setTextColor(textColor); return tv; } // 没什么作用 @Override public int getNextGroupOnPan(int group, float degree) { return 0; } // 下一个页面要显示的数据 @Override public int getNextGroupOnZoom(int group, boolean isZoomIn) { return (group + 1) % getGroupCount();// 确保循环显示 } }
3 设置StellarMap参数
若想第一页就显示数据,那么方法setGroup(0, true);必须放在setAdapter(adapter)后面,其他方法顺序无所谓;
public void initStellarMap() { stellarMap.setGroup(0, true); stellarMap.setInnerPadding(padding, padding, padding, padding);// 设置textView的内边距 stellarMap.setRegularity(15, 15); }
源码:http://download.csdn.net/detail/ss1168805219/9485126
相关文章推荐
- Mac Terminal增强对git命令支持
- Android Studio中配置AndroidAnnotations,遇到的问题及解决方法
- 一个点绕另一个点旋转a度 问题
- [笔记]《深入浅出Ext JS(第2版)》
- 编译hello.ko到目标板运行
- 冒泡、插入、希尔排序
- 【学习笔记----数据结构01-概述】
- textField 代理方法 输入内容后 内容判空控制
- 伪数组与伪数组转化为数组
- Python学习笔记(四)dict和set
- 比较kmalloc/vmalloc/get_free_pages
- 分析facebook的AsyncDisplayKit框架,async-display使用async-transaction
- CentOs conn mysql
- 兼容加载Xml字符串
- Tensorflow cifar模型源码
- Service详解(二):Service生命周期
- 浮躁_该怎么平息?
- ImportError: No module named _caffe
- 46、外部调用内部类的方法
- 线索化二叉树--单链表实现