【发布时间】:2011-06-10 08:50:32
【问题描述】:
在我的应用程序中,我想保留状态栏但使其背景与主屏幕相同。
所以我创建了一个自定义主题来设置应用程序背景:
<resources>
<style name="Theme.Shelves" parent="android:Theme">
<item name="android:windowBackground">@drawable/background_shelf</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
然后放到manifest里面:
<application android:icon="@drawable/icon"
android:theme="@style/Theme.Shelves"
android:label="@string/app_name">
<activity android:name=".HelloWorld"
android:label="@string/app_name">
得到这个:
Screen shot 2 http://i1178.photobucket.com/albums/x370/BinhNguyen84/device.png
除了状态栏和主屏幕之间的分隔线之外,一切都很好。我认为这是因为文本视图填充,所以我将其设置为零但没有任何改变。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello World");
setContentView(tv);
tv.setPadding(0,0,0,0);
}
【问题讨论】:
-
这就是我所期待的i1178.photobucket.com/albums/x370/BinhNguyen84/device1.png。由于最大链接限制,我无法将其放在我的问题中
标签: java android background themes statusbar