導航:首頁 > 操作系統 > android設置標題欄背景

android設置標題欄背景

發布時間:2025-01-01 17:13:50

A. android怎麼用基類控制標題欄

[html] view plain
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_titlebar"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#ed4255" >

<TextView
android:id="@+id/text_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="marquee"
android:gravity="center_horizontal|center"
android:singleLine="true"
android:text="標題欄"
android:textColor="#ffffffff"
android:textSize="20dp" />

<TextView
android:id="@+id/button_backward"
android:layout_width="60dp"
android:layout_height="match_parent"
android:drawableLeft="@drawable/back_arrow"
android:drawablePadding="6dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="返回"
android:textColor="#ffffffff"
android:textSize="18dp"
android:visibility="invisible" />

<TextView
android:id="@+id/button_forward"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:drawablePadding="6dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="提交"
android:textColor="#ffffffff"
android:textSize="18dp"
android:visibility="invisible" />

</RelativeLayout>

B. android dialog 怎麼設置全屏

theme.notitlebar
:
不顯示應�'a8程序標題欄
theme.notitlebar.fullscreen
:
不顯示應用程序標題欄,並全屏
theme.light
:背景為白色
theme.light.notitlebar
:
白色背景並無標題欄
theme.light.notitlebar.fullscreen
:
白色背景,無標題欄,全屏
theme.black
:
背景黑色
theme.black.notitlebar
:
黑色背景並無標題欄
theme.black.notitlebar.fullscreen
:
黑色背景,無標題欄,全屏
theme.wallpaper
:
用系統桌面為應用程序背景
theme.wallpaper.notitlebar
:
用系統桌面為應用程序背景,且無標題欄
theme.wallpaper.notitlebar.fullscreen
:
用系統桌面為應用程序背景,無標題欄,全屏
theme.translucent
:
透明背景

C. 怎麼自定義Android標題欄修改TitleBar的布局

Android程序默認的Activity標題欄只能顯示一段文字,而且不能改變它的布局、顏色、標題欄的高度等。如果想要在標題欄加上個圖標、button、輸入框、進度條、修改標題欄顏色等,只能使用自定義的標題欄。自定義標題欄可以通過在onCreate函數中添加以下代碼來實現,需要注意的是代碼的順序必須按照下面的樣式,否則將無效。
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.mainactivity); //Activity的布局
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.titlebar); //標題欄的布局
雖然上面這樣可以在標題欄加入一些控制項,但是仍然不能改變標題欄的高度、背景色,要想達到這個目的,只能使用theme(主題)。因此往project里先添加一個style。改變背景色修改android:windowTitleBackgroundStyle的值,改變標題欄高度則修改android:windowTitleSize的值。下面是一個示例:






接著再修改AndroidManifest.xml文件,找到要自定義標題欄的Activity,添加上android:theme值,比如:

Java代碼
android:theme值就是上面那個style.xml文件里定義的一個style的name值。

按照以上的步驟,修改標題欄布局、高度、背景色的功能就實現了。

閱讀全文

與android設置標題欄背景相關的資料

熱點內容
宿舍裝的電信怎麼加密 瀏覽:745
為什麼壓縮文件解壓後變少了 瀏覽:426
現在安卓充電器普遍是什麼型號 瀏覽:714
9日均線36均線主圖指標源碼 瀏覽:349
程序員阿里文化完整版 瀏覽:98
早間新聞在哪個app上面可以看 瀏覽:954
工作啦app注冊的信息怎麼刪去 瀏覽:378
滾動轉子式製冷壓縮機 瀏覽:873
美國編程用什麼軟體 瀏覽:571
圖片加密防盜用 瀏覽:616
dbscan演算法python源碼 瀏覽:849
固態硬碟文件夾刪不掉 瀏覽:717
陽泉工會app怎麼培訓報名 瀏覽:669
編程圖形二級題 瀏覽:549
怎樣知道自己的app存在哪個文件夾 瀏覽:853
電子手帳app怎麼下載 瀏覽:810
app播客是怎麼賺錢的 瀏覽:380
東南亞伺服器是什麼檔次 瀏覽:132
手機app怎麼操控電熱水器 瀏覽:839
python爬蟲框架推薦 瀏覽:518