0
A
回答
0
這是一個真正的解決方法,但我得到了我wanted.I把一個TextView在我的佈局的頂部,獲得以下尺寸,使它看起來像一個標題欄
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vehicle_view"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
//Title bar
<TextView
android:layout_width="fill_parent"
android:layout_height="24dip"
android:id="@+id/title_bar_text"
android:background="#dddddd"
android:textColor="#150517"
android:text="Enter Text">
</TextView>
............................. //Rest of layout elements
.............................
.............................
</LinearLayout>
如果有人得到了一個更好的答案,以某種方式添加一個額外的標題欄,而不會像我做的那樣改變佈局發佈它,我會接受作爲答案。
0
這thread將讓你開始在你的活動構建自己的標題欄的XML文件,並使用它
這裏是上面的鏈接的內容的簡要概括 - 這只是設置顏色文本和標題欄的背景的 - 沒有調整尺寸,沒有按鈕,就在simpliest樣品
RES /佈局/ mytitle.xml - 這是將代表標題欄
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitle"
android:text="This is my new title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/titletextcolor"
/>
視圖RES /值/ themes.x ml - 我們想保留默認的Android主題,只需要改變標題背景的背景顏色。所以我們創建一個主題,繼承默認的主題,並將背景樣式設置爲我們自己的樣式。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="customTheme" parent="android:Theme">
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>
</style>
</resources>
RES /價值/ styles.xml - 這是我們設定的主題中使用我們想要的顏色爲標題背景
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="WindowTitleBackground">
<item name="android:background">@color/titlebackgroundcolor</item>
</style>
</resources>
RES /價值/ colors.xml - 這裏的設置顏色你想
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="titlebackgroundcolor">#3232CD</color>
<color name="titletextcolor">#FFFF00</color>
</resources>
在AndroidManifest.xml中,設置在應用程序(爲整個應用程序)的主題,無論是屬性還是在活動(僅限本次活動)標籤
<activity android:name=".CustomTitleBar" android:theme="@style/customTheme" ...
From the Activity (called CustomTitleBar) :
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
}
相關問題
- 1. Android的活動 - 從一個屏幕到另一個屏幕
- 2. 如何將微調器添加到活動的標題欄?
- 3. 如何從Android中的屏幕底部滑動一個活動
- 4. 如何在Android中從一個活動/屏幕檢索數據到另一個活動/屏幕?
- 5. android活動到libGdx屏幕
- 6. 如何使一個活動出現在Android屏幕的一半屏幕上
- 7. Android:將活動添加到主屏幕上的菜單
- 8. 將標題添加到android活動
- 9. 如何在android的活動的標題欄中添加關閉按鈕?
- 10. 添加額外的側邊欄到Wordpress
- 11. 如何動態添加額外的請求到一個Guzzle池?
- 12. 如何添加一個額外的按鈕到窗口標題欄,所以它將作爲標準工作?
- 13. 在標籤式活動中添加額外的片段
- 14. 如何將微調添加到動作欄的標題欄?
- 15. 添加一個開始/標題屏幕到Pygame代碼
- 16. 添加額外的鏈接標題
- 17. 如何添加一個額外的行和列到數組中?
- 18. qmake如何添加額外的標誌
- 19. 添加一個動作欄到Theme.Black.NoTitleBar Android
- 20. 將活動的User_id添加到標題
- 21. Android的工作室:不能額外的圖標添加到操作欄
- 22. android在同一個活動中添加兩個工具欄?
- 23. 如何添加一個額外的鏈接到wordpress的摘錄
- 24. 如何更改android活動中的標題欄顏色?
- 25. 如何將一個屏幕移動到LibGDX中的另一個屏幕?
- 26. 如何在android鎖定屏幕上執行一個活動?
- 27. 如何通過點擊活動中的按鈕將appwidget添加到主屏幕
- 28. 如何將圖像添加到android 3.0的標題欄?
- 29. 如何在移動到android平臺的下一個屏幕時關閉屏幕?
- 30. 在android中單擊一個活動的屏幕截圖
這是您對「簡要」摘要的想法嗎? :p – 2011-03-05 09:12:14
我已經看到這在http://stackoverflow.com/questions/2251714/set-title-background-color/2251787#2251787。這是爲了自定義標題欄。我正在通過框架尋找一個選項來添加一個額外的標題欄.. – rogerstone 2011-03-05 11:23:56