1. 程式人生 > >Android自定義標題欄

Android自定義標題欄

補充:

這位大佬的方法設定完成後是白色的背景,如果需要自定義背景可以在style中新增:

<style name="CustomWindowTitleBackground">
        <item name="android:background">#000000</item>
    </style>

    <style name="CustomTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:windowTitleSize">100dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
        <item name="android:windowActionBar" tools:ignore="NewApi">false</item>
    </style>

如果需要將狀態列與標題欄設定相同顏色,可以在Activity的onCreate的方法中加入:

getWindow().setStatusBarColor(0xff000000);

還沒有找到使狀態列顏色隨標題欄改變而改變的方法,那位大佬路過,請指點下小弟~