Home > Mobile >  Ask: LayoutParams add controls related questions
Ask: LayoutParams add controls related questions

Time:11-14

Novice to consult everybody, online to find the following code, can be in the top of the screen to generate a high degree of 30 transparent view, block holds off the top of the notification bar, I want to make two changes now, excuse me how to change? Thank you all!

1: change the transparency of the transparent view
2: in the view and add a TextView display text




WindowManager manager=((WindowManager) getApplicationContext () getSystemService (Context. WINDOW_SERVICE));
WindowManager. LayoutParams localLayoutParams=new WindowManager. LayoutParams ();
LocalLayoutParams. Type=WindowManager. LayoutParams. TYPE_SYSTEM_ERROR;
LocalLayoutParams. Gravity=gravity. TOP;

LocalLayoutParams. Flags=WindowManager. LayoutParams. FLAG_NOT_FOCUSABLE |
. LayoutParams. FLAG_NOT_TOUCH_MODAL |

WindowManager. LayoutParams. FLAG_LAYOUT_IN_SCREEN;
LocalLayoutParams. Width=WindowManager. LayoutParams. MATCH_PARENT;
LocalLayoutParams. Height=(int) (30 * getResources (). GetDisplayMetrics () scaledDensity);


LocalLayoutParams. Format=PixelFormat. TRANSPARENT;
View the View=new CustomViewGroup (this);

Manager. AddView (view, localLayoutParams);

CodePudding user response:

View the View=new CustomViewGroup (this); Have you this sentence is not a control, direct operation this view, to control the transparency, plus TextView

CodePudding user response:

I am a rookie, bother express code
  • Related