android->code add view addContentVIew

 

@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate (savedInstanceState);

	TextView tv = new TextView(this);
	FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
	FrameLayout.LayoutParams.WRAP_CONTENT,
	FrameLayout.LayoutParams.WRAP_CONTENT);
	// Set the position where the ad appears (floating at the top)
	params.topMargin = 0;
	params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;

	tv.setText("I wipe...dynamic layout");
	addContentView(tv, params);
	// setContentView(tv);
}

 

If it is service, it can be used 

getWindow().addContentView(l1, params);

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326562690&siteId=291194637