一、改变Tab栏的位置。
java代码。在TabActivity的oncreate方法中添加
setContentView(R.layout.tab_host);
其中 Layout tab_host.xml 是从系统资源文件中抠出来之后略作修改。
系统原来的 tab_host.xml内容如下
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/layout/tab_content.xml
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http:///apk/res/android"
android:layout_width="wrap_content"
android:layout_height="64dip"
android:orientation="vertical"
>
</RelativeLayout>
View view1 = inflater.inflate(R.layout.tab_in, null);;
View view2 = inflater.inflate(R.layout.tab_in, null);;
View view3 = inflater.inflate(R.layout.tab_in, null);;
view1 .setBackgroundResource(R.drawable.record_upload_button_stateful);
view2 .setBackgroundResource(R.drawable.record_download_button_stateful);
view3 .setBackgroundResource(R.drawable.record_receive_button_stateful);
tabHost.addTab(tabHost
.newTabSpec("view1")
.setIndicator(view1)
);
tabHost.addTab(tabHost
.newTabSpec("view2")
.setIndicator(view2)
);
tabHost.addTab(tabHost
.newTabSpec("view3")
.setIndicator(view3)
);