设置Title的种种
在自定义标题栏时遇到了问题,我需要在标题栏加两个button,并且字要居中。
解决方法是将网上流行的两种方法结合即可。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ThemeForCustomTitle" parent="android:Theme">
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowTitleBackgroundStyle">@style/StatusBarBackground</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="StatusBarBackground">
<item name="android:background">@drawable/progress</item>
</style>
</resources>
然后在manifest里面设置theme="ThemeForCustomTitle"。
Activity里面
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
TextView titleText = (TextView) findViewById(R.id.titleText);
titleText.setText(R.string.listenPA);
2153

被折叠的 条评论
为什么被折叠?



