Ui review-layout manager framelayout (neon light)

Source: Internet
Author: User

1> frame concept. Components in the layout are stacked together like cards programmed by windows.

package com.brady.est;import java.util.Timer;import java.util.TimerTask;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.support.v7.app.ActionBarActivity;import android.view.Menu;import android.view.MenuItem;import android.widget.TextView;public class MainActivity extends ActionBarActivity {    private int[] textViews = new int[] { R.id.view1, R.id.view2, R.id.view3,            R.id.view4, R.id.view5, R.id.view6 };    private int[] colors = new int[] { R.color.color1, R.color.color2,            R.color.color3, R.color.color4, R.color.color5, R.color.color6 };    private int currentImage = 0;    private TextView views[] = new TextView[textViews.length];    private Handler handle = new Handler() {        public void handleMessage(Message msg) {            if (msg.what == 0x444) {                for (int i = textViews.length - 1; i > 0; i--) {                    views[i].setBackgroundResource(colors[currentImage                            % colors.length]);                    currentImage++;                }            }        }    };    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        for (int i = 0; i < textViews.length; i++) {            views[i] = (TextView) findViewById(textViews[i]);        }        new Timer().schedule(new TimerTask() {            @Override            public void run() {                handle.sendEmptyMessage(0x444);            }        }, 0, 300);    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.main, menu);        return true;    }    @Override    public boolean onOptionsItemSelected(MenuItem item) {        // Handle action bar item clicks here. The action bar will        // automatically handle clicks on the Home/Up button, so long        // as you specify a parent activity in AndroidManifest.xml.        int id = item.getItemId();        if (id == R.id.action_settings) {            return true;        }        return super.onOptionsItemSelected(item);    }}

Framelayout layout file:

<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" Android: Orientation = "vertical" tools: context = "com. brady. EST. mainactivity "> <! -- Introduce custom components <COM. brady. view. drawview Android: layout_width = "match_parent" Android: layout_height = "match_parent"/> --> <textview Android: Id = "@ + ID/view1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Background = "# A32" Android: layout_gravity = "center" Android: width = "300px" Android: height = "300px"/> <textview Android: Id = "@ + ID/view2" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: background = "# c32" Android: layout_gravity = "center" Android: width = "250px" Android: Height = "250px"/> <textview Android: id = "@ + ID/view3" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Background = "# E32" Android: layout_gravity = "center" Android: width = "200px" Android: Height = "200px"/> <textview Android: Id = "@ + ID/view4" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Background = "# f32" Android: layout_gravity = "center" Android: width = "150px" Android: Height = "150px"/> <textview Android: id = "@ + ID/view5" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Background = "# B32" Android: layout_gravity = "center" Android: width = "100px" Android: Height = "100px"/> <textview Android: Id = "@ + ID/view6" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Background = "# c32" Android: layout_gravity = "center" Android: width = "50px" Android: Height = "50px"/> </framelayout>

Color Resource XML file:

<?xml version="1.0" encoding="utf-8"?><resources>    <color name="color1" translatable="false">#0f0</color>    <color name="color2" translatable="false">#f00</color>    <color name="color3" translatable="false">#00f</color>    <color name="color4" translatable="false">#0c0</color>    <color name="color5" translatable="false">#c00</color>    <color name="color6" translatable="false">#00c</color></resources>

 

Ui review-layout manager framelayout (neon light)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.