最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)3D標(biāo)簽云效果

 更新時(shí)間:2021年06月23日 15:27:14   作者:MrZhao_PerfectCode  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)3D標(biāo)簽云效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

最近業(yè)務(wù)需求,要求實(shí)現(xiàn)一個(gè)3D星球環(huán)繞效果,經(jīng)過(guò)百般查找,終于找到了這個(gè)功能。

來(lái)先看看效果圖:

首先還是添加第三方依賴庫(kù):

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); 
 } 
} 

一個(gè)適配器代碼:

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); 
 } 
} 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

莲花县| 铜鼓县| 寻乌县| 天等县| 汉寿县| 井冈山市| 凤阳县| 朝阳区| 长治市| 萝北县| 天全县| 新巴尔虎右旗| 美姑县| 青海省| 通江县| 满洲里市| 罗平县| 武鸣县| 大连市| 六盘水市| 大埔县| 沈阳市| 公安县| 金坛市| 云浮市| 灵台县| 新密市| 高雄县| 淮北市| 临高县| 吉首市| 高州市| 白玉县| 阿合奇县| 巴林左旗| 岳西县| 镶黄旗| 平定县| 河北区| 阿克苏市| 谢通门县|