導航:首頁 > 操作系統 > 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設置標題欄背景相關的資料

熱點內容
stata方差檢驗命令 瀏覽:335
解壓後文件夾里的內容丟失 瀏覽:713
解壓無敵視頻 瀏覽:688
什麼是伺服器辨認不了 瀏覽:126
java如何調用類方法 瀏覽:481
管理孩子的app叫什麼 瀏覽:544
壓縮活動軌跡 瀏覽:674
6米梁加密筋 瀏覽:79
怎麼學好ps如何學好編程 瀏覽:300
c編譯器廠商 瀏覽:114
簡述編譯程序以及解釋程序 瀏覽:3
linux升級kernel 瀏覽:176
入侵伺服器挖礦是什麼罪 瀏覽:47
房屋解壓資料丟了怎麼辦 瀏覽:810
java文件行讀寫 瀏覽:544
影城網上售票系統源碼 瀏覽:634
防疫就是命令歌曲 瀏覽:204
滴滴號碼加密怎麼解除 瀏覽:844
模具編程的職責 瀏覽:944
華為ssh改加密演算法 瀏覽:149