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

熱點內容
html5編程題 瀏覽:837
乾燥機製冷壓縮機一開就跳動 瀏覽:386
吉林壓縮空氣流量監測 瀏覽:616
根據地址獲取經緯度php 瀏覽:10
小天才app的應用中心有什麼應用 瀏覽:768
java代碼整理 瀏覽:259
安卓單個胎壓怎麼配對 瀏覽:627
linux將文件清空 瀏覽:476
一套前端編譯平台 瀏覽:598
安卓9x用什麼框架 瀏覽:72
萬用表怎樣量壓縮機漏電 瀏覽:548
無線路由器雲登錄伺服器未連接 瀏覽:781
aes是公鑰密碼演算法 瀏覽:698
linuxphp編譯參數 瀏覽:534
安卓手機怎麼永久關閉後台啟動 瀏覽:40
網站phpjavascript 瀏覽:453
64位java內存 瀏覽:418
女程序員學習方法 瀏覽:383
工程數學線性代數pdf 瀏覽:681
提升程序員技術檔次的書 瀏覽:691