码迷,mamicode.com
首页 > Windows程序 > 详细

window

时间:2015-04-22 08:14:31      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

public class TeacherInfoActivity extends Activity {
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.teacherinfo_aty);
tv=(TextView) findViewById(R.id.tvw);
tv.setOnClickListener(new OnClickListener(){
@SuppressLint("NewApi") @Override
public void onClick(View v) {
System.out.println("这里执行了");
final RelativeLayout rlt=new RelativeLayout(getApplicationContext());

final TextView tv_fullScreen=new TextView(TeacherInfoActivity.this);
tv_fullScreen.setText("我要把整个屏幕沾满了");
tv_fullScreen.setBackgroundColor(Color.parseColor("#ffff00"));
WindowManager.LayoutParams params=new WindowManager.LayoutParams();
params.height=WindowManager.LayoutParams.MATCH_PARENT;
params.width=WindowManager.LayoutParams.MATCH_PARENT;
params.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
params.format=PixelFormat.TRANSLUCENT;
params.type=WindowManager.LayoutParams.TYPE_APPLICATION;
final WindowManager wm=(WindowManager) getSystemService(Context.WINDOW_SERVICE);
wm.addView(rlt, params);
RelativeLayout.LayoutParams params_tv_fullscreen= new RelativeLayout.LayoutParams(200,150);
rlt.setGravity(Gravity.CENTER);
rlt.addView(tv_fullScreen,params_tv_fullscreen);
TextView tv_image= new TextView(getApplicationContext());
tv_image.setBackground(getApplicationContext().getResources().getDrawable(R.drawable.ic_launcher));
RelativeLayout.LayoutParams params_tv_image= new RelativeLayout.LayoutParams(100,50);
params_tv_image.setMargins(50, -20, 0, 0);
rlt.addView(tv_image,params_tv_image);


tv_fullScreen.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

Toast.makeText(TeacherInfoActivity.this, "我被点击了,我要干掉自己!", 0).show();
wm.removeView(rlt);
}
});
}

});
}

}

window

标签:

原文地址:http://www.cnblogs.com/hanyong/p/4446287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!