更改Activity的最底层的布局

public void attachToActivity(Activity activity) {
	mActivity = activity;
	TypedArray a = activity.getTheme().obtainStyledAttributes(
			new int[] { android.R.attr.windowBackground });
	int background = a.getResourceId(0, 0);
	a.recycle();
	ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
	ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
	decorChild.setBackgroundResource(background);
	decor.removeView(decorChild);
	addView(decorChild);
	setContentView(decorChild);
	decor.addView(this);
}

 

posted @ 2016-03-04 11:24  swalka`x  阅读(282)  评论(0编辑  收藏  举报