Android realizes TextView text reflection effect

Record the reflection effect of the TextView today, display a string of text, and then display its reflection below the text, first on the effect map:

Android realizes TextView text reflection effect

The most important thing is the getDrawingCache() method in View, which takes the image in the cache and draws it.

Not much nonsense, I want to write a time with reflection, time can move. First write a View with time walking, this is very simple, get the current time, then open a thread, get the current time once every second, and then display it on the TextView, of course, we write the control, we need to inherit the TextView, the code as follows:

Package com.alex.reflecttextview;

Import java.uTIl.Calendar;

Import android.content.Context;

Import android.os.Handler;

Import android.os.Message;

Import android.text.format.DateFormat;

Import android.uTIl.AttributeSet;

Import android.widget.TextView;

Public class TImeView extends TextView {

Private staTIc final int MESSAGE_TIME = 1;

Public timeView(Context context, AttributeSet attrs) {

Super(context, attrs);

New TimeThread().start();

}

Public class TimeThread extends Thread {

@Override

Public void run() {

Do {

Try {

Message msg = new Message();

Msg.what = MESSAGE_TIME;

mHandler.sendMessage(msg);

Thread.sleep(1000);

} catch (InterruptedException e) {

e.printStackTrace();

}

} while (true);

}

}

Private Handler mHandler = new Handler() {

@Override

Public void handleMessage(Message msg) {

super.handleMessage(msg);

Switch (msg.what) {

Case MESSAGE_TIME:

setTime();

Break;

Default:

Break;

}

}

};

Public void setTime() {

Long sysTime = System.currentTimeMillis();

Calendar calendar = Calendar.getInstance();

calendar.setTimeInMillis(sysTime);

String sysTimeStr = DateFormat.format("hh:mm", sysTime).toString();

If(calendar.get(Calendar.AM_PM) == 0) {

sysTimeStr += " AM";

} else {

sysTimeStr += “PM”;

}

setText(sysTimeStr.replace("1", "1")));

}

}

SMD Transformer


SMD transformer Description: small size, high working frequency, high adhesion performance, small distribution inductance;It is mainly used for module power supply, laptop, mobile phone and ultra-thin electric appliance.

The transformer consists of an iron core (or magnetic core) and a coil. The coil has two or more windings, of which the winding connected to the power supply is called the primary winding and the rest is called the secondary winding.It can change ac voltage, current and impedance.The simplest core transformer consists of an iron core made of a soft magnetic material and two coils with different turns on the core.



SMD Transformer, Ee16 Transformer, Power Transformer, Electric Transformer

YANGZHOU POSITIONING TECH CO., LTD. , https://www.yzpst.com

Posted on