├── .classpath ├── .gitattributes ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── Demo ├── README.md ├── ic_launcher-web.png ├── libs ├── android-support-v4.jar └── randomlayout.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── layout │ └── activity_main.xml ├── menu │ └── main.xml ├── values-sw600dp │ └── dimens.xml ├── values-sw720dp-land │ └── dimens.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── src └── com └── shitou └── randomlayout └── MainActivity.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # ========================= 29 | # Operating System Files 30 | # ========================= 31 | 32 | # OSX 33 | # ========================= 34 | 35 | .DS_Store 36 | .AppleDouble 37 | .LSOverride 38 | 39 | # Thumbnails 40 | ._* 41 | 42 | # Files that might appear on external disk 43 | .Spotlight-V100 44 | .Trashes 45 | 46 | # Directories potentially created on remote AFP share 47 | .AppleDB 48 | .AppleDesktop 49 | Network Trash Folder 50 | Temporary Items 51 | .apdisk 52 | 53 | # Windows 54 | # ========================= 55 | 56 | # Windows image file caches 57 | Thumbs.db 58 | ehthumbs.db 59 | 60 | # Folder config file 61 | Desktop.ini 62 | 63 | # Recycle Bin used on file shares 64 | $RECYCLE.BIN/ 65 | 66 | # Windows Installer files 67 | *.cab 68 | *.msi 69 | *.msm 70 | *.msp 71 | 72 | # Windows shortcuts 73 | *.lnk 74 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | 随机摆放文字带飞入飞出效果 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #运行效果 2 | ![qcl](http://a3.qpic.cn/psb?/V13yyfT93I2jgl/qiDRn5SqcmDfOMIWmW4vnRl5MA8FW*vURZlwZi.84CU!/b/dBwBAAAAAAAA&bo=bwGGAgAAAAACF9k!&rf=viewer_4) 3 | 4 | 5 | 6 | #使用步骤 7 | 1,这个开源项目的使用只需要导入jar包就行。 8 | 这里可以实现文字的随机摆布,并且这些随机的文件可以显示不同的颜色, 9 | 不同的大小。文字进来时有个飞入效果。退出时有个飞出效果 10 | 11 | 2,使用的时候可以使用StellarMap这个类来创建显示随机文字的控件 12 | stellarMap = new StellarMap(this); 13 | // 1.设置内部的TextView距离四周的内边距 14 | int padding = 15; 15 | stellarMap.setInnerPadding(padding, padding, padding, padding); 16 | stellarMap.setAdapter(new StellarMapAdapter()); 17 | // 设置默认显示第几组的数据 18 | stellarMap.setGroup(0, true);// 这里默认显示第0组 19 | // 设置x和y方向上的显示的密度 20 | stellarMap.setRegularity(15, 15);// 如果值设置的过大,有可能造成子View摆放比较稀疏 21 | 22 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/ic_launcher-web.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/randomlayout.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/libs/randomlayout.jar -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiushi123/randomlayout/ba1c506d894f9ad0935948f7c3e20f9a0ec0adf4/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 随机摆放文字带飞入飞出效果 5 | Settings 6 | Hello world! 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/com/shitou/randomlayout/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.shitou.randomlayout; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Random; 5 | 6 | import android.app.Activity; 7 | import android.graphics.Color; 8 | import android.os.Bundle; 9 | import android.util.TypedValue; 10 | import android.view.View; 11 | import android.widget.FrameLayout; 12 | import android.widget.TextView; 13 | 14 | import com.shitou.googleplay.lib.randomlayout.StellarMap; 15 | import com.shitou.googleplay.lib.randomlayout.StellarMap.Adapter; 16 | import com.shitou.randomlayou.R; 17 | 18 | public class MainActivity extends Activity { 19 | private StellarMap stellarMap; 20 | private ArrayList list = new ArrayList(); 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | // 简单的设置要显示的文字源 28 | for (int i = 0; i < 3; i++) { 29 | for (int j = 0; j < 11; j++) { 30 | list.add("第" + i + "组" + "文字" + j); 31 | } 32 | } 33 | 34 | stellarMap = new StellarMap(this); 35 | // 1.设置内部的TextView距离四周的内边距 36 | int padding = 15; 37 | stellarMap.setInnerPadding(padding, padding, padding, padding); 38 | stellarMap.setAdapter(new StellarMapAdapter()); 39 | // 设置默认显示第几组的数据 40 | stellarMap.setGroup(0, true);// 这里默认显示第0组 41 | // 设置x和y方向上的显示的密度 42 | stellarMap.setRegularity(15, 15);// 如果值设置的过大,有可能造成子View摆放比较稀疏 43 | 44 | // 把fragment显示至界面,new出fragment对象 45 | FrameLayout fl = (FrameLayout) findViewById(R.id.fl); 46 | fl.addView(stellarMap); 47 | } 48 | 49 | class StellarMapAdapter implements Adapter { 50 | /** 51 | * 返回多少组数据 52 | */ 53 | @Override 54 | public int getGroupCount() { 55 | return 3; 56 | } 57 | 58 | /** 59 | * 每组多少个数据 60 | */ 61 | @Override 62 | public int getCount(int group) { 63 | return 11; 64 | } 65 | 66 | /** 67 | * group: 当前是第几组 position:是当前组的position 68 | */ 69 | @Override 70 | public View getView(int group, int position, View convertView) { 71 | final TextView textView = new TextView(MainActivity.this); 72 | // 根据group和组中的position计算出对应的在list中的位置 73 | int listPosition = group * getCount(group) + position; 74 | textView.setText(list.get(listPosition)); 75 | 76 | // 1.设置随机的字体大小(随机大小) 77 | Random random = new Random(); 78 | textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 79 | random.nextInt(15) + 14);// 14-29 80 | // 2.上色,设置随机的字体颜色 81 | // 如果三原色的值过大会偏白色,过小会偏黑色,所以应该随机一个中间的颜色的值 82 | int red = random.nextInt(150) + 50;// 50-199 83 | int green = random.nextInt(150) + 50;// 50-199 84 | int blue = random.nextInt(150) + 50;// 50-199 85 | int textColor = Color.rgb(red, green, blue);// 在rgb三原色的基础上混合出一种新的颜色 86 | textView.setTextColor(textColor); 87 | return textView; 88 | } 89 | 90 | /** 91 | * 虽然定义了,但是并没有什么乱用 92 | */ 93 | @Override 94 | public int getNextGroupOnPan(int group, float degree) { 95 | return 0; 96 | } 97 | 98 | /** 99 | * 当前组缩放完成之后下一组加载哪一组的数据 group: 表示当前是第几组 100 | */ 101 | @Override 102 | public int getNextGroupOnZoom(int group, boolean isZoomIn) { 103 | // 0->1->2->0 104 | return (group + 1) % getGroupCount(); 105 | } 106 | 107 | } 108 | 109 | } 110 | --------------------------------------------------------------------------------