您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“怎么使用自定義Layout重新設(shè)置標(biāo)題欄”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“怎么使用自定義Layout重新設(shè)置標(biāo)題欄”吧!
Android UI缺省的標(biāo)題欄由android:label 定義,顯示在屏幕左上角,Android允許Activity自定義標(biāo)題欄,使用自定義Layout重新設(shè)置標(biāo)題欄,比如實(shí)現(xiàn)Windows Mobile 風(fēng)格的標(biāo)題欄。
App->Activity->Custom Title 重新將Activity標(biāo)題欄定義為左右兩個(gè)文本框,其Layout定義R.layout.custom_title_1如下:
(下面的xml中包含了一左一右兩個(gè)文本框。
與每個(gè)Activity對(duì)應(yīng)的除了使用由setContentView設(shè)置的Content View之外,還有一個(gè)Windows類對(duì)象,Windows 類對(duì)象用于控制標(biāo)題欄,可以允許自定義標(biāo)題欄或是不顯示標(biāo)題欄。)
<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/screen” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <TextView android:id=”@+id/left_text” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:text=”@string/custom_title_left” /> <TextView android:id=”@+id/right_text” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentRight=”true” android:text=”@string/custom_title_right” /> </RelativeLayout>
Windows 定義了一些Feature,允許開發(fā)人員做些定制:自定義標(biāo)題欄對(duì)應(yīng)的Feature ID為Window.FEATURE_CUSTOM_TITLE。
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.custom_title); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
到此,相信大家對(duì)“怎么使用自定義Layout重新設(shè)置標(biāo)題欄”有了更深的了解,不妨來實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。