国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android實現3D標簽云效果

2019-10-22 18:10:22
字體:
來源:轉載
供稿:網友

最近業務需求,要求實現一個3D星球環繞效果,經過百般查找,終于找到了這個功能。

來先看看效果圖:

Android,標簽云

首先還是添加第三方依賴庫:

compile 'com.moxun:tagcloudlib:1.1.0' 

布局:

<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="match_parent"  android:layout_height="match_parent"  tools:context="com.example.administrator.my3d_demo.MainActivity">   <com.moxun.tagcloudlib.view.TagCloudView   android:id="@+id/tag_cloud"   android:layout_width="match_parent"   android:layout_height="match_parent"   android:layout_margin="10dp"   app:autoScrollMode="uniform"   app:darkColor="#ff00ff00"   app:lightColor="#ffff0000"   app:radiusPercent="0.5"   app:scrollSpeed="3" />  </android.support.constraint.ConstraintLayout> 

MainActivity代碼:

package com.example.administrator.my3d_demo;  import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle;  import com.moxun.tagcloudlib.view.TagCloudView;  public class MainActivity extends AppCompatActivity {   @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.activity_main);    TagCloudView tagCloudView = (TagCloudView) findViewById(R.id.tag_cloud);   tagCloudView.setBackgroundColor(Color.LTGRAY);    TextTagsAdapter tagsAdapter = new TextTagsAdapter(new String[20]);   tagCloudView.setAdapter(tagsAdapter);  } } 

一個適配器代碼:

package com.example.administrator.my3d_demo;  import android.content.Context; import android.support.annotation.NonNull; import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.TextView;  import com.moxun.tagcloudlib.view.TagsAdapter;  import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random;  public class TextTagsAdapter extends TagsAdapter {   private List<String> dataSet = new ArrayList<>();   public TextTagsAdapter(@NonNull String... data) {   dataSet.clear();   Collections.addAll(dataSet, data);  }   @Override  public int getCount() {   return dataSet.size();  }   @Override  public View getView(final Context context, final int position, ViewGroup parent) {   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};*/   Random rand = new Random();   int randNum = rand.nextInt(9);    TextView tv = new TextView(context);   ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(100, 100);   tv.setLayoutParams(lp);   tv.setText("No." + name[randNum]);   tv.setGravity(Gravity.CENTER);   tv.setOnClickListener(new View.OnClickListener() {    @Override    public void onClick(View v) {     Log.e("Click", "Tag " + position + " clicked.");    }   });   return tv;  }   @Override  public Object getItem(int position) {   return dataSet.get(position);  }   @Override  public int getPopularity(int position) {   return position % 7;  }   @Override  public void onThemeColorChanged(View view, int themeColor) {   ((TextView) view).setTextColor(themeColor);  } } 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊吾县| 肥乡县| 盘锦市| 镇康县| 铅山县| 电白县| 道孚县| 民乐县| 白朗县| 赤城县| 博客| 富川| 清水河县| 河津市| 余江县| 邻水| 济南市| 新密市| 临洮县| 阳新县| 龙江县| 义乌市| 神农架林区| 延吉市| 宾川县| 镶黄旗| 海口市| 湄潭县| 论坛| 张家口市| 无棣县| 北川| 禄劝| 合作市| 富顺县| 七台河市| 凤山市| 金华市| 琼结县| 固原市| 陈巴尔虎旗|