Bubble(16)

来源:互联网 发布:淘宝淘气值怎么看 编辑:程序博客网 时间:2024/05/01 12:03

设置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);



原创粉丝点击