自定义活动为弹出框样式:android:theme="@android:style/Theme.Dialog";
自定义活动title:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
此处研究一下Window,它是一个抽象类,提供了对窗口的高层抽象,使用它可以自定义窗口背景、窗口title等样式。
基本步骤如下:
先在setContentView之前调用requestWindowFeature(Window feature id)。然后调用getWindow().setFeatureInt将新的样式布局应用到activity上。
客户化window feature时需要注意:
1. 要在setContentView之前调用requestFeature。由于requestWindowFeature = getWindow().requestFeature,所以调用requestWindowFeature 也可。
2. 不能将其他title相关feature与FEATURE_CUSTOM_TITLE一起使用。