android 标题
一个接着一个的activity,写啊写,调啊调,后来,终于发觉,activity的标题栏好难看,好单调啊。咱们为了吸引用户的眼球,得搞点个性化的东西。
自定义标题栏的方法,网上一搜一大堆,我也稍微提一下,oncreate中加上如下代码就行:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(view); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#66cccccc" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello" /></LinearLayout>
<item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>
<style name="WindowTitleBackground"> <item name="android:background">@android:drawable/title_bar</item> </style>
<item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
<resources> <style name="XTheme" parent="android:Theme"> <!-- Window attributes --> <item name="android:windowTitleStyle">@style/XWindowTitle</item> <item name="android:windowTitleBackgroundStyle">@style/StatusBarBackground</item> <item name="android:windowContentOverlay">@null</item> </style> </resources>
<resources> <style name="StatusBarBackground"> <item name="android:background">@drawable/shape</item> </style> <style name="XWindowTitle" parent="android:WindowTitle"> <item name="android:shadowColor">#BB000000</item> <item name="android:shadowRadius">0</item> </style> </resources>
<activity android:name=".Entry" android:label="@string/app_name" android:theme="@style/XTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>