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. Android:带标题栏的全屏活动
- 3. 如何从Android中的活动转到上一个屏幕?
- 4. 如何添加和删除Android中的一个活动的屏幕?
- 5. 如何将微调器添加到活动的标题栏?
- 6. 如何从Android中的屏幕底部滑动一个活动
- 7. 如何在Android中从一个活动/屏幕检索数据到另一个活动/屏幕?
- 8. 如何添加一个额外的菜单WordPress的管理屏幕
- 9. Android - 如何更改一个活动的标题栏文本?
- 10. (JGraphX)如何添加一个额外的标签到顶点?
- 11. 如何使一个活动出现在Android屏幕的一半屏幕上
- 12. 将标题添加到android活动
- 13. 如何在android的活动的标题栏中添加关闭按钮?
- 14. android活动到libGdx屏幕
- 15. android如何在屏幕上加载一个活动?
- 16. 添加额外的侧边栏到Wordpress
- 17. 如何动态添加额外的请求到一个Guzzle池?
- 18. Android的屏幕变黑,如果我得到了一个活动
- 19. 如何添加一个额外的按钮到窗口标题栏,所以它将作为标准工作?
- 20. 如何活动/屏幕之间的Android
- 21. 在标签式活动中添加额外的片段
- 22. 如何添加填充到android屏幕?
- 23. 将Prefrences屏幕添加到具有自定义窗口标题的活动
- 24. 在android 2.1中添加一个活动到另一个活动
- 25. 如何将微调添加到动作栏的标题栏?
- 26. Android:如何在Dialog活动的标题栏中设置图标?
- 27. 添加一个开始/标题屏幕到Pygame代码
- 28. 从一个标签栏移动到另一个标签栏时屏幕变黑
- 29. 添加额外的链接标题
- 30. CSS/HTML如何添加一个'标题'到我的菜单栏?
这是您对“简要”摘要的想法吗? :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