如何定制Activity的标题栏
生活随笔
收集整理的這篇文章主要介紹了
如何定制Activity的标题栏
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
????????setContentView(R.layout.main);
????????//自定義標(biāo)題欄
????????mWindow = getWindow();
????????mWindow.setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.titlebar);
?
titlebar.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal"android:layout_width="fill_parent"android:layout_height="wrap_content" ><TextViewandroid:text="@string/app_name"android:textColor="#000"android:paddingRight="3.0dip"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextViewandroid:text="@string/battery_text"android:textColor="#000"android:paddingRight="3.0dip"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextViewandroid:id="@+id/battery_text"android:textColor="#00f"android:layout_width="wrap_content"android:layout_height="wrap_content"/> </LinearLayout>?上述的話只是適合android4.0一下的版本,如果需要針對android4.0以上的版本的話需要我們使用自己的樣式
<style name="TitleBackgroundColor"><item name="android:background">@color/background_color</item></style><style name="titlestyle" parent="android:Theme" ><item name="android:windowTitleSize">40dip</item> <item name="android:windowTitleBackgroundStyle">@style/TitleBackgroundColor</item></style> 然后在配置文件中加上,OK<activity android:name="com.ygl.ui.LoginActivity"android:theme="@style/titlestyle"></activity>
?
轉(zhuǎn)載于:https://www.cnblogs.com/DASOU/p/4261038.html
總結(jié)
以上是生活随笔為你收集整理的如何定制Activity的标题栏的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vs entityframwork V
- 下一篇: EntityFramework_MVC4