在4.0以上自定义标题栏

时间:2014-10-27 12:48:38   收藏:0   阅读:185

需要设置的几句代码:

	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>


 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!