我按照这一SO问题的说明:http://stackoverflow.com/questions/3438276/change-title-bar-text-in-android
我能成功地创建自己的工具栏,但是当我申请一个背景颜色为我的布局,颜色不整个标题栏跨越。目前还有Android的灰色背景色的残余。
下面是我的XML:
<?XML版本=1.0编码=UTF-8&GT?;< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android 机器人:layout_width =400像素 机器人:layout_height =FILL_PARENT 机器人:方向=横向的android:背景=@色/ solid_blue>< ImageView的机器人:ID =@ + ID /标志 机器人:layout_width =57px 机器人:layout_height =WRAP_CONTENT 机器人:背景=@绘制/图标>< / ImageView的><的TextView 机器人:ID =@ + ID / myTitle 机器人:文字=StockDroid由 机器人:layout_width =FILL_PARENT 机器人:layout_height =FILL_PARENT 机器人:文字颜色=#FFFFFF />< / LinearLayout中>
解决方案
剩余的东西上的链接本身作为一个评论人
编辑:
您已经错过了设置自定义样式的窗口标题,并在 Android的设置在清单中的东西:为活动主题
属性
你有你的RES /价值/ styles.xml文件创建此两个样式:
<样式名称=MyTheme的父=安卓主题> <项目名称=机器人:windowTitleSize> 50像素< /项目> <项目名称=机器人:windowTitleBackgroundStyle> @风格/ WindowTitleBackground < /项目> < /风格><样式名称=WindowTitleBackground父=机器人:WindowTitleBackground> <项目名称=机器人:背景> @android:彩色/透明 < /项目> < /风格>
那么你有你的Manifest,它是喜欢你设定风格主题:
<活动机器人:名字=活动 机器人:标签=@字符串/ APPNAME机器人:主题=@风格/ MyTheme的/>
希望它帮助。
I have followed the instructions from this SO question: http://stackoverflow.com/questions/3438276/change-title-bar-text-in-android
I am able to successfully create my own titlebar, however when I apply a background color to my layout, the color doesn't span across the entire titlebar. There are still remnants of the android gray background color.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400px"
android:layout_height="fill_parent"
android:orientation="horizontal" android:background="@color/solid_blue">
<ImageView android:id="@+id/logo"
android:layout_width="57px"
android:layout_height="wrap_content"
android:background="@drawable/icon">
</ImageView>
<TextView
android:id="@+id/myTitle"
android:text="StockDroid by"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFF"
/>
</LinearLayout>
解决方案
Remaining stuff is on that link itself as a comment man.
Edit:
The stuff you have missed to set the custom style for the Window Title and set it at the Manifest by the android:theme
attribute for the activity.
you have to create this two style in your res/values/styles.xml file:
<style name="MyTheme" parent="android:Theme">
<item name="android:windowTitleSize">50px</item>
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground
</item>
</style>
<style name="WindowTitleBackground" parent="android:WindowTitleBackground">
<item name="android:background">@android:color/transparent
</item>
</style>
then you have to set you style as theme in you Manifest that is like:
<activity android:name=".activity"
android:label="@string/appname" android:theme="@style/MyTheme" />
hope it helps.
相关推荐
最新文章