源码简介:我的博客有相关介绍:http://blog.csdn.net/csdnfml/article/details/49589931 最近有几个需求是关于仿IOS的几个特效,没有做过所以仿照着他们的成果,整合了一下给大家分享一下
源码效果:
源码片段:
- /** 两个按钮切换 */
- private void initView() {
- mSegmentView = (SegmentView) findViewById(R.id.segment_view);
- mSegmentView.setSegmentText("你好", 0);
- mSegmentView.setSegmentText("我好", 1);
- mSegmentView.setOnSegmentViewClickListener(new SegmentView.onSegmentViewClickListener() {
- @Override
- public void onSegmentViewClick(View v, int position) {
- switch (position) {
- case 0:
- Toast.makeText(mContext, "你好", Toast.LENGTH_SHORT).show();
- break;
- case 1:
- Toast.makeText(mContext, "我好", Toast.LENGTH_SHORT).show();
- break;
- default:
- break;
- }
- }
- });
- }
- /** 三个按钮切换 */
- private void initViewThree() {
- mSegmentViewThree = (SegmentViewThree) findViewById(R.id.segment_view_three);
- mSegmentViewThree.setSegmentText("你好", 0);
- mSegmentViewThree.setSegmentText("我好", 1);
- mSegmentViewThree.setSegmentText("他好", 2);
- mSegmentViewThree.setOnSegmentViewClickListener(new SegmentViewThree.onSegmentViewClickListener() {
- @Override
- public void onSegmentViewClick(View v, int position) {
- switch (position) {
- case 0:
- Toast.makeText(mContext, "你好", Toast.LENGTH_SHORT).show();
- break;
- case 1:
- Toast.makeText(mContext, "我好", Toast.LENGTH_SHORT).show();
- break;
- case 2:
- Toast.makeText(mContext, "他好", Toast.LENGTH_SHORT).show();
- break;
- default:
- break;
- }
- }
- });
- }