Android霓虹灯效果
来源:互联网 发布:学习英语口语的软件 编辑:程序博客网 时间:2024/04/29 05:26
Android霓虹灯效果
页面布局文件:
activity_main.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TextView android:id="@+id/tv1" android:layout_width="300dip" android:layout_height="300dip" android:layout_gravity="center" /> <TextView android:id="@+id/tv2" android:layout_width="240dip" android:layout_height="240dip" android:layout_gravity="center" /> <TextView android:id="@+id/tv3" android:layout_width="180dip" android:layout_height="180dip" android:layout_gravity="center" /> <TextView android:id="@+id/tv4" android:layout_width="120dip" android:layout_height="120dip" android:layout_gravity="center" /> <TextView android:id="@+id/tv5" android:layout_width="60dip" android:layout_height="60dip" android:layout_gravity="center" /></FrameLayout>
主要业务操作代码:
MainActivity.java
public class MainActivity extends Activity { private int[] colors = new int[] {0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFF00FF, 0xFF00FFFF}; private int[] nextColorsPointers = new int[] {1, 2, 3, 4, 0}; private View[] views; private int currentColorPointer = 0; private Handler handler; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); views = new View[] {findViewById(R.id.tv5), findViewById(R.id.tv4), findViewById(R.id.tv3), findViewById(R.id.tv2),findViewById(R.id.tv1)}; handler = new Handler(); Runnable runnable = new Runnable() { @Override public void run() { int nextColorPointer = currentColorPointer; for(int i = views.length - 1; i >= 0; i --) { views[i].setBackgroundColor(colors[nextColorsPointers[nextColorPointer]]); nextColorPointer = nextColorsPointers[nextColorPointer]; } currentColorPointer ++; if(currentColorPointer == 5) { currentColorPointer = 0; } handler.postDelayed(this, 300); } }; handler.postDelayed(runnable, 300); }}
0 0
- Android霓虹灯效果
- android 霓虹灯效果
- 霓虹灯效果
- Android帧布局实现霓虹灯的效果
- 初学Android,FrameLayout霓虹灯效果(五)
- android学习笔记之简易霓虹灯效果
- Android:帧布局实现霓虹灯的效果
- 【Android】使用FrameLayout布局实现霓虹灯效果
- Android之霓虹灯实现小效果
- Android:霓虹灯
- android布局之帧布局-----霓虹灯效果实现
- android学习笔记6:使用Framelayout实现霓虹灯效果
- Android学习之霓虹灯效果--所遇问题
- Android笔记(2)---帧布局实现霓虹灯效果
- 学到一个android小应用-霓虹灯闪烁效果界面
- IOS 霓虹灯效果
- 霓虹灯效果(UIView)
- 3种霓虹灯效果
- cf472D Design Tutorial: Inverse the Problem
- LeetCode 解题集
- cocos2dx3.2版本利用shader实现sprite灰态图的正确方法
- hdu2099 水~
- 国庆计划
- Android霓虹灯效果
- 【Android】自定义控件的绘制过程
- 2014-09-30
- CSDN 四川大学线下比赛第一题
- 2014/9/30 22:55 十一放假的前奏曲
- 5高并发服务器:socket IPC
- 【问题解决】Ubuntu 12.04 网络连接有规律的时断时续
- Android四角布局
- 【Android】事件传递机制