博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自定义控件:飞入飞出的效果
阅读量:4129 次
发布时间:2019-05-25

本文共 1543 字,大约阅读时间需要 5 分钟。

效果图:

  用到4个类(copy)

1 布局:

 

 * 步骤:

 *  准备:复制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);	}

源码:

你可能感兴趣的文章
Python-OpenCV人脸检测(代码)
查看>>
python+opencv之视频人脸识别
查看>>
人脸识别(OpenCV+Python)
查看>>
6个强大的AngularJS扩展应用
查看>>
网站用户登录系统设计——jsGen实现版
查看>>
第三方SDK:讯飞语音听写
查看>>
第三方SDK:JPush SDK Eclipse
查看>>
第三方开源库:imageLoader的使用
查看>>
自定义控件:飞入飞出的效果
查看>>
自定义控件:动态获取控件的高
查看>>
第三方开源库:nineoldandroid:ValueAnimator 动态设置textview的高
查看>>
第三方SDK:百度地图SDK的使用
查看>>
Android studio_迁移Eclipse项目到Android studio
查看>>
JavaScript setTimeout() clearTimeout() 方法
查看>>
CSS border 属性及用border画各种图形
查看>>
转载知乎-前端汇总资源
查看>>
JavaScript substr() 方法
查看>>
JavaScript slice() 方法
查看>>
JavaScript substring() 方法
查看>>
HTML 5 新的表单元素 datalist keygen output
查看>>