Android实现3 d标签云效果

  

最近业务需求,要求实现一个3 d星球环绕效果,经过百般查找,终于找到了这个功能。

  

来先看看效果图:

  

 Android实现3 d标签云效果

  

首先还是添加第三方依赖库:

        编译的com.moxun: tagcloudlib: 1.1.0      

布局:         & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; android.support.constraint。ConstraintLayout xmlns: android=" http://schemas.android.com/apk/res/android "   xmlns:应用=" http://schemas.android.com/apk/res-auto "   xmlns:工具=" http://schemas.android.com/tools "   android: layout_width=" match_parent "   android: layout_height=" match_parent "   工具:上下文=癱om.example.administrator.my3d_demo.MainActivity”比;      & lt; com.moxun.tagcloudlib.view.TagCloudView   android: id=癅 + id/tag_cloud”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android: layout_margin=" 10 dp”   应用:autoScrollMode="统一"   应用:darkColor=" # ff00ff00”   应用:lightColor=" # ffff0000”   应用:radiusPercent=" 0.5 "   应用:scrollSpeed=3/比;      & lt;/android.support.constraint.ConstraintLayout>之前      

MainActivity代码:

        包com.example.administrator.my3d_demo;      进口android.graphics.Color;   进口android.support.v7.app.AppCompatActivity;   进口android.os.Bundle;      进口com.moxun.tagcloudlib.view.TagCloudView;      公开课MainActivity延伸AppCompatActivity {      @Override   保护空白>   包com.example.administrator.my3d_demo;      进口android.content.Context;   进口android.support.annotation.NonNull;   进口android.util.Log;   进口android.view.Gravity;   进口android.view.View;   进口android.view.ViewGroup;   进口android.widget.TextView;      进口com.moxun.tagcloudlib.view.TagsAdapter;      进口java.util.ArrayList;   进口java.util.Collections;   进口并不知道;   进口java.util.Random;      公开课TextTagsAdapter延伸TagsAdapter {      私人List数据集=new ArrayList<在();      公共TextTagsAdapter (@NonNull字符串…数据){   dataSet.clear ();   集合。addAll(数据集、数据);   }      @Override   公共int getCount () {   返回dataSet.size ();   }      @Override   公众视线getView(最后的上下文语境,最后int位置,ViewGroup父){   String [] name={“1”、“2”、“3”、“4”、“5”、“6”、“7”、“8”,“9”};/* int [] name={R.mipmap.ic_launcher、R.mipmap.ic_launcher R.mipmap.ic_launcher,   R.mipmap.ic_launcher、R.mipmap.ic_launcher R.mipmap.ic_launcher,   R.mipmap.ic_launcher、R.mipmap.ic_launcher R.mipmap.ic_launcher} */随机兰德=new随机();   int randNum=rand.nextInt (9);      TextView电视=new TextView(上下文);   ViewGroup。新ViewGroup MarginLayoutParams lp=arginLayoutParams (100、100);   tv.setLayoutParams (lp);   tv.setText(“不”。+ [randNum])名称;   tv.setGravity (Gravity.CENTER);   电视。setOnClickListener(新View.OnClickListener () {   @Override   公共空间onClick(查看v) {   日志。e(“点击”、“标签”+位置+“点击”。);   }   });   返回电视;   }      @Override   公共对象getItem (int位置){   返回dataSet.get(位置);   }      @Override   公共int getPopularity (int位置){   返回位置% 7;   }      @Override   公共空间onThemeColorChanged(视图视图,int themeColor) {   ((TextView)视图).setTextColor (themeColor);   }   }      

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

Android实现3 d标签云效果