android实现页面下方的Tab效果
来源:互联网 发布:淘宝登录注册流程图 编辑:程序博客网 时间:2024/05/06 13:34
实现采用TabHost组件。
1、XML布局文件:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout
android:gravity="bottom"
android:layout_weight="1"
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<TabWidget
android:layout_weight="0"
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</TabHost>
注意<FrameLayout>标签和<TabWidget>标签的顺序。
android:layout_weight的设置使位置靠下,否则默认是在上面的。
2、activity文件
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maintabs);
// Resource object to get Drawables
Resources res = getResources();
tabHost = getTabHost();
// Resusable TabSpec for each tab
TabHost.TabSpec spec;
// Reusable Intent for each tab
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this,HomeTab.class);
// Initialize a TabSpec for each tab and add it to the TabHost
String str_tabhome=res.getString(R.string.tab_home);
spec = tabHost.newTabSpec(str_tabhome).setIndicator(str_tabhome,res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);
String str_tab02=res.getString(R.string.tab02);
spec = tabHost.newTabSpec(str_tab02).setIndicator(str_tab02,res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
1、XML布局文件:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout
android:gravity="bottom"
android:layout_weight="1"
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<TabWidget
android:layout_weight="0"
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</TabHost>
注意<FrameLayout>标签和<TabWidget>标签的顺序。
android:layout_weight的设置使位置靠下,否则默认是在上面的。
2、activity文件
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maintabs);
// Resource object to get Drawables
Resources res = getResources();
tabHost = getTabHost();
// Resusable TabSpec for each tab
TabHost.TabSpec spec;
// Reusable Intent for each tab
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this,HomeTab.class);
// Initialize a TabSpec for each tab and add it to the TabHost
String str_tabhome=res.getString(R.string.tab_home);
spec = tabHost.newTabSpec(str_tabhome).setIndicator(str_tabhome,res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);
String str_tab02=res.getString(R.string.tab02);
spec = tabHost.newTabSpec(str_tab02).setIndicator(str_tab02,res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
3、效果如下:
- android实现页面下方的Tab效果
- 实现屏幕下方展示的TAB分页
- 实现屏幕下方展示的TAB分页
- 实现屏幕下方展示的tab
- 实现屏幕下方展示的TAB分页
- Android之tab实现切换页面效果—FragmentTabHost
- jquery实现页面滚动到最下方自动按分页的形式加载内容效果
- Android自定义下方导航Tab
- Fragment嵌套Fragment实现多tab页面的效果
- android ActivityGroup实现Tab效果
- android实现tab切换效果
- android实现中间卡位下方viewpager效果展示
- Android 各种实现Tab效果的实现方式
- Tab切换效果的实现
- Android实现带动画效果的Tab Menu
- Android--通过ActivityGroup实现Tab的选卡效果
- android中实现tab标签切换时的一些效果
- 【Android进阶】实现各种各样的Tab切换效果
- oracle 日志分析工具logminer的安装使用
- ffmpeg 无法解析 外部符号
- ajax php jquery (1)
- 18.观察者模式--Observer
- 让 IPhone 程序的调试信息只在 debug 模式下输出
- android实现页面下方的Tab效果
- Windows验证静态只用的端口方法
- Windows 7 以管理员身份运行
- 浅谈JAVA中的四个核心概念
- CUGB 1009 合唱队形 【DP】
- 分享非常有用的Java程序 (关键代码) (一)
- Poj 1703 / Poj 1182 并查集二题
- oracle 笔记6(Fundamentals II)
- 动态循环给onclick赋值(解决闭包问题)