关注android Activity的theme(或者该翻译为主题),是由两个网上的android面试题引发的.
1.activity的生命周期
2.怎样把一个Activity设置成窗口的样式
先说说activity的生命周期.两个Activity在切换时,第二个Activity如果把第一个Activity遮盖住了,那第一个Activity必然会调用onStop方法,而如果没有遮盖,则在调用了onPause方法后就不再调用onStop方法.这一点,我在先前有专门去探索过.http://www.cnblogs.com/leipei2352/archive/2011/08/09/2132279.html
因此在学习Activity生命周期时,为了让第二个Activity不完全把第一个Activity遮盖住,我设置了第二个Activity的theme:
<activity android:name=".activity02" android:theme="@android:style/Theme.Dialog"></activity>
再说说由这个theme引出的其它知识点.设置这个窗口theme,其实我是从教材里看到的,但教材中并未提到其他theme.我在eclipse中打开theme的引用后,新打开了一个文件: C:\Program Files\Android\android-sdk\platforms\android-8\data\res\values\theme.xml .在这个文件中定义了不少我还不了解的theme.不过还好,每个theme项都在前面有描述.
本想列在此处,发现有点不现实,那么多,全列在这地方,难免有刷字数的嫌疑.对theme比较感兴趣话,可以自己去读这个文件.我只在这里列一个比较有意思的theme的定义.
to see through them to the windows behind. This sets up the translucent
flag and appropriate animations for your windows. -->
>
>
>
>
<!-- Note that we use the base animation style here (that is no
animations) because we really have no idea how this kind of
activity will be used. -->
>
>