Textview1.settextcolor (Color.argb (255, 0, 255, 0)); Text transparency
Control is set to semitransparent:
The name of the control. Getbackground (). Setalpha (int); int is between 0-255
PackageNet.android.alpha;ImportAndroid.widget.TextView;ImportAndroid.os.Bundle;ImportAndroid.view.ViewGroup;Importandroid.app.Activity;ImportAndroid.graphics.Color;Importandroid.widget.LinearLayout; Public classToumingextendsActivity {Final intWrap_content =ViewGroup.LayoutParams.WRAP_CONTENT; Public voidonCreate (Bundle icicle) {Super. OnCreate (Icicle); LinearLayout LinearLayout=NewLinearLayout ( This); Linearlayout.setorientation (linearlayout.vertical); Setcontentview (LinearLayout); TextView Textview1=NewTextView ( This); Textview1.settext ("All opacity = 255"); //Textview1.setbackgroundcolor (Color.argb (255, 0, 255, 0));//Background TransparencyTextview1.settextcolor (Color.argb (255, 0, 255, 0));//Text TransparencyLinearlayout.addview (Textview1,Newlinearlayout.layoutparams (wrap_content, wrap_content)); TextView Textview2=NewTextView ( This); Textview2.settext ("Partial penetration of 155"); Textview2.setbackgroundcolor (Color.argb (155, 0, 255, 0));//Background TransparencyTextview2.settextcolor (Color.argb (155, 0, 255, 0));//Text TransparencyLinearlayout.addview (Textview2,Newlinearlayout.layoutparams (wrap_content, wrap_content)); TextView TEXTVIEW3=NewTextView ( This); Textview3.settext ("Partially transparent 55"); Textview3.setbackgroundcolor (Color.argb (55, 0, 255, 0));///Background TransparencyTextview3.settextcolor (Color.argb (55, 0, 255, 0));//Text TransparencyLinearlayout.addview (TEXTVIEW3,Newlinearlayout.layoutparams (wrap_content, wrap_content)); TextView Textview4=NewTextView ( This); Textview4.settext ("All transparent 0"); //Textview4.setbackgroundcolor (Color.argb (0, 0, 255, 0));//Background TransparencyTextview4.settextcolor (Color.argb (0, 0, 255, 0));//Text TransparencyLinearlayout.addview (TEXTVIEW4,Newlinearlayout.layoutparams (wrap_content, wrap_content)); }}
Most critical section, setting font transparency ARGB (Alpha, R, G, B)