Android 自定義標(biāo)題欄背景
設(shè)置標(biāo)題欄背景
1> 準(zhǔn)備背景圖片: background_pix.png
注:用背景圖片比用顏色好處,可以讓背景看起來(lái)有凹凸感.
2> drawable文件夾下放xml文件
bitmap_repeat.xml
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/title_pic" android:tileMode="repeat"> </bitmap>
3> 定義樣式文件style.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- 自定義標(biāo)題樣式 --> <style name="StatusBarBackground"> <item name="android:background">@drawable/bitmap_repeat </item> </style> <style name="XTheme" parent="android:Theme"> <!-- Window attributes --> <item name="android:windowTitleBackgroundStyle">@style/StatusBarBackground </item> </style> <!-- 自定義標(biāo)題樣式 --> </resources>
4> 在manifest.xml中引用主題android:theme="@style/XTheme"
<activity android:name=".activity.MainActivty" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" android:theme="@style/XTheme"> </activity>
自定義標(biāo)題欄layout文件ct_title.xml
注: ct_title.xml文件中用如下方式設(shè)置標(biāo)題欄背景會(huì)出下填充不滿效果
android:background="@drawable/bitmap_repeat "
在activity中引用
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.ct_title); }
相關(guān)文章
Flutter之Timer實(shí)現(xiàn)短信驗(yàn)證碼獲取60s倒計(jì)時(shí)功能的代碼
這篇文章主要介紹了Flutter之Timer實(shí)現(xiàn)短信驗(yàn)證碼獲取60s倒計(jì)時(shí)功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-073種Android隱藏頂部狀態(tài)欄及標(biāo)題欄的方法
這篇文章主要為大家詳細(xì)介紹了3種Android隱藏頂部狀態(tài)欄及標(biāo)題欄的方法,還涉及一種隱藏Android 4.0平板底部狀態(tài)欄的方法,感興趣的小伙伴們可以參考一下2016-02-02Android高級(jí)xml布局之輸入框EditText設(shè)計(jì)
這篇文章主要為大家詳細(xì)介紹了Android高級(jí)xml布局之輸入框EditText設(shè)計(jì),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12Android實(shí)現(xiàn)EditText輸入金額
EditText是Android中一個(gè)非常實(shí)用的控件,有很多InputType,可以來(lái)達(dá)到不同的輸入效果,下面通過(guò)實(shí)例代碼給大家解析android實(shí)現(xiàn)edittext輸入金額,需要的朋友參考下吧2016-12-12Android訪問(wèn)php取回json數(shù)據(jù)實(shí)例
Android訪問(wèn)php取回json數(shù)據(jù),實(shí)現(xiàn)代碼如下,遇到訪問(wèn)網(wǎng)絡(luò)的權(quán)限不足在AndroidManifest.xml中,需要進(jìn)行如下配置2013-06-06Android Drawerlayout實(shí)現(xiàn)側(cè)滑菜單效果
這篇文章主要為大家詳細(xì)介紹了Android Drawerlayout實(shí)現(xiàn)側(cè)滑菜單效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10Android自定義button點(diǎn)擊效果的兩種方式
這篇文章主要為大家詳細(xì)介紹了Android自定義button點(diǎn)擊效果的兩種方式,感興趣的小伙伴們可以參考一下2016-05-05