我已按照此问题的说明进行操作:如何更改操作栏上的文本 https://stackoverflow.com/questions/3438276/change-title-bar-text-in-android
我能够成功创建自己的标题栏,但是当我将背景颜色应用于布局时,该颜色不会跨越整个标题栏。仍然有 Android 灰色背景颜色的残余。
这是我的 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>
剩下的东西就在上面link https://stackoverflow.com/questions/3438276/change-title-bar-text-in-android本身作为一个comment http://labs.makemachine.net/2010/03/custom-android-window-title/ man.
Edit:
您错过了为窗口标题设置自定义样式并将其设置在清单中的内容android:theme
活动的属性。
您必须在 res/values/styles.xml 文件中创建这两种样式:
<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>
那么你必须在清单中将样式设置为主题,如下所示:
<activity android:name=".activity"
android:label="@string/appname" android:theme="@style/MyTheme" />
希望能帮助到你。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)