我在我的android应用程序中使用带有背景图像的标题栏。Android自定义标题栏 - 隐藏文本
值/ custom_styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TitlebarBackgroundStyle">
<item name="android:background">@drawable/titlebar</item>
</style>
<style name="Theme.MyCustomTheme" parent="android:Theme">
<item name="android:windowTitleBackgroundStyle">@style/TitlebarBackgroundStyle</item>
<item name="android:windowTitleSize">45dp</item>
</style>
</resources>
布局/ titlebar.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:gravity="center_vertical">
<ImageView
android:id="@+id/header"
android:src="@drawable/titlebar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
清单:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/Theme.MyCustomTheme">
这工作得很好至今。
我想现在唯一要做的就是隐藏标题栏的文字...
我想:
<item name="android:textSize">0dp</item>
,但没有运气。有没有什么方法可以设置透明度或其他属性,让我看到背景图像而不是文本?
感谢您的想法 罗恩
我想我应该将图像从后台到前台移动。也许这会避免文本的问题。 – Ron 2010-11-27 00:55:34