default:
break;
}
}
protected void reload() {
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
}
其实设置主题必须在任何view创建之前,所以我们不可能在activity的onCreate之后来更改主题,如果一定要做,就只能调用setTheme(),然后调用recreate(),重新创建一个activity,并且销毁上一个activity; 所以这个方案并不可行,整个界面必须销毁重建。 已知的Android theme修改方式
-
AndroidManifest 设置Activity Theme
-
在Activity setContentView执行前 调用setTheme
可以通过其他方式修改Activity windowIsTranslucent 属性吗?
方案B+:反射动态设置Activity windowIsTranslucent
查阅Activity源码,看一下他是如何变成透明的
/**
-
Convert a translucent themed Activity {@link android.R.attr#windowIsTranslucent} back from
-
opaque to translucent following a call to {@link #convertFromTranslucent()}.
-
-
Calling this allows the Activity behind this one to be seen again. Once all such Activities
-
have been redrawn {@link TranslucentConversionListener#onTranslucentConversionComplete} will
-
be called indicating that it is safe to make this activity translucent again. Until
-
{@link TranslucentConversionListener#onTranslucentConversionComplete} is called the image
-
behind the frontmost Activity will be indeterminate.
-
-
This call has no effect on non-translucent activities or on activities with the
-
{@link android.R.attr#windowIsFloating} attribute.
-
@param callback the method to call when all visible Activities behind this one have been
-
drawn and it is safe to make this Activity translucent again.
-
@param options activity options delivered to the activity below this one. The options
-
are retrieved using {@link #getActivityOptions}.