首页 > 代码库 > 在4.0以上自定义标题栏

在4.0以上自定义标题栏

需要设置的几句代码:

	private void setCustomTitle() {		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);		setContentView(R.layout.main);		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,				R.layout.customtitle);	}


另外要引用自定义的样式:

    <style name="CustomizedWindowTitleBackground">        <item name="android:background">#044BF6</item>    </style>    <style name="titlebarstyle" parent="android:Theme">        <item name="android:windowTitleSize">48dp</item>        <item name="android:windowTitleBackgroundStyle">@style/CustomizedWindowTitleBackground</item>    </style>


 

在4.0以上自定义标题栏