最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android編程實現(xiàn)自定義title功能示例

 更新時間:2017年03月06日 11:05:18   作者:aloxc  
這篇文章主要介紹了Android編程實現(xiàn)自定義title功能,結(jié)合具體實例形式分析了Android自定義title的具體實現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了Android編程實現(xiàn)自定義title功能。分享給大家供大家參考,具體如下:

這里我在前面加了個logo,而且改變了title的背景和高度。

首先編寫title的布局文件,title.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_title"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/title_logo"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="20sp"
android:layout_marginLeft="80dip"
android:textColor="#ffffff"
/>
</LinearLayout>

然后在Activity的onCreate()里加上這三句話:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.title);

需要注意的是這三句話的順序不能變。到這里只是改變了title的布局,下面改變背景和高度,這就需要改變Activity的theme。

在values文件夾下新建文件style.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">@drawable/bg_title</item>
</style>
<style name="title_style" parent="android:Theme">
<item name="android:windowTitleSize">44dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
</resources>

最后在AndroidManifest.xml里面加上:

<activity android:name=".sysinfo"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/title_style"
>

這樣就實現(xiàn)了自定義title。

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論

揭西县| 上犹县| 漳州市| 噶尔县| 喜德县| 静宁县| 台山市| 白山市| 祁连县| 西林县| 耒阳市| 扶余县| 铜川市| 宁远县| 武山县| 嘉义县| 盱眙县| 华阴市| 武宁县| 宁远县| 长子县| 聂荣县| 河间市| 新巴尔虎右旗| 沈丘县| 中山市| 宽甸| 眉山市| 西吉县| 金湖县| 寿光市| 綦江县| 盐津县| 东宁县| 东宁县| 星子县| 正蓝旗| 正蓝旗| 沙坪坝区| 青海省| 怀安县|