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

熱點內容
什麼叫伺服器內部錯誤4o4 瀏覽:486
單片機原理復習 瀏覽:433
打不開頭條任務伺服器怎麼辦 瀏覽:643
戰雷錄像在哪個文件夾 瀏覽:464
加密驗證的門禁卡 瀏覽:741
java輸出心 瀏覽:532
程序員的身體素質調查 瀏覽:383
python做一個登錄系統怎麼改界面 瀏覽:884
楊穎緩解壓力的方法 瀏覽:144
約苗app在哪裡改地址 瀏覽:819
tuxedo的加密協議 瀏覽:728
javapdftojpg 瀏覽:712
程序員軟考課程 瀏覽:274
Android框架工程師 瀏覽:387
計算機編程機器人工程師招聘 瀏覽:683
怎麼添加mite伺服器 瀏覽:581
方舟怎麼命令一隻恐龍手機版 瀏覽:712
javaqq郵箱發送 瀏覽:171
cms淘寶客網站源碼 瀏覽:932
如何連接選股伺服器 瀏覽:30