android之实现底部TabHost
先说布局文件,如下:利用android:layout_alignParentBottom="true" 实现底部显示
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:background="@drawable/g" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> </TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/tabFirst" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <AnalogClock android:id="@+id/widget31" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true"> </AnalogClock> </RelativeLayout>> <RelativeLayout android:id="@+id/tabSecond" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <DigitalClock android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </DigitalClock> </RelativeLayout> </FrameLayout> </RelativeLayout></TabHost>package com.cloay;
import android.app.TabActivity;import android.graphics.Color;import android.os.Bundle;import android.widget.TabHost;import android.widget.TabHost.OnTabChangeListener;import android.widget.Toast;public class TabTestActivity extends TabActivity { TabHost tabHost; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //获取TabHost对象 tabHost = getTabHost(); // tabHost.setup(); //新建一个newTabSpec,设置标签和图标(setIndicator),设置内容(setContent) tabHost.addTab(tabHost.newTabSpec("Test one").setIndicator("",getResources().getDrawable(android.R.drawable.ic_menu_call)).setContent(R.id.tabFirst)); tabHost.addTab(tabHost.newTabSpec("Test two").setIndicator("",getResources().getDrawable(android.R.drawable.ic_menu_camera)).setContent(R.id.tabSecond)); //设置TabHost的背景颜色 tabHost.setBackgroundColor(Color.argb(150,22,70,150)); //设置TabHost的背景图片资源// tabHost.setBackgroundResource(R.drawable.bg); //设置当前现实哪一个标签 tabHost.setCurrentTab(0); //0为标签ID //标签切换处理,用setOnTabChangedListener tabHost.setOnTabChangedListener(new OnTabChangeListener(){ public void onTabChanged(String tabId){ Toast.makeText(TabTestActivity.this, "This is a Test!", Toast.LENGTH_LONG).show(); } }); }}android之实现底部TabHost的更多相关文章
- Android底部TabHost API
今天在项目中遇到了底部TabHost,顺便就写了一个底部TabHost的api继承即可使用非常简单,以下为源代码: 首先是自定义的TabHostActivity,如果要使用该TabHost继承该类即可 ...
- Android 自学之选项卡TabHost
选项卡(TabHost)是一种非常实用的组件,TabHost可以很方便地在窗口上放置多个标签页,每个标签页相当于获得了一个与外部容器相同大小的组建摆放区域.通过这种方式,就可以在一个容器中放置更多组件 ...
- [置顶]
xamarin android Fragment实现底部导航栏
前段时间写了篇关于Fragment的文章,介绍了基础的概念,用静态和动态的方式加载Fragment Xamarin Android Fragment的两种加载方式.下面的这个例子介绍xamarin ...
- Android UI-实现底部切换标签(fragment)
Android UI-实现底部切换标签(fragment) 前言 本篇博客要分享的一个UI效果--实现底部切换标签,想必大家在一些应用上面遇到过这样的效果了,最典型的就是微信了,能够左右滑动切换页面. ...
- 【Android】带底部指示的自定义ViewPager控件
在项目中经常需要使用轮转广告的效果,在android-v4版本中提供的ViewPager是一个很好的工具,而一般我们使用Viewpager的时候,都会选择在底部有一排指示物指示当前显示的是哪一个pag ...
- Android BottomSheet:底部弹出Fragment面板(4)
Android BottomSheet:底部弹出Fragment面板(4) BottomSheet不仅可以弹出轻量级的定制好的面板(见附录文章5,6,7),还可以弹出"重"的 ...
- Android UI-仿微信底部导航栏布局
现在App基本的标配除了侧滑菜单,还有一个就是底部导航栏,常见的聊天工具QQ,微信,购物App都有底部导航栏,用户可以随便切换看不同的内容,说是情怀也好,用户体验也罢.我们开发的主要的还是讲的是如何如 ...
- android学习笔记十——TabHost
TabHost——标签页 ==> TabHost,可以在窗口放置多个标签页,每个标签页相当于获得了一个与外部容器相同大小的组件摆放区域. 通过此种方式可以实现在一个容器放置更多组件(EG:通话记 ...
- 【Android 界面效果22】Android的Tab与TabHost
Tab与TabHost 这就是Tab,而盛放Tab的容器就是TabHost 如何实现?? 每一个Tab还对应了一个布局,这个就有点好玩了.一个Activity,对应了多个功能布局. ①新建一个Tab项 ...
随机推荐
- Image与Bitmap的区别及相互转换
1. Image.FromFile()返回的是某个继承自Image的具体类的对象,在这里,就是Bitmap或者Metafile其中之一.这应该算是factory pattern的一种形式.所以,Ima ...
- A generic error occurred in GDI+的解决方案
转自智慧光原文A generic error occurred in GDI+. 解决方法 使用image1.RotateFlip(RotateFlipType.Rotate90FlipNone)方法 ...
- tree的所有节点都勾选上或者取消勾选
还有一个功能,就是让tree的所有节点都勾选上或者取消勾选,在api中找了一下有一个方法: check target 选中指定节点. 那我们只能是选中根节点后,实现全选. getRoot none 获 ...
- jquery ui的css设计
jquery ui 是当前最强大的UI库之一,其两大卖点是对IE6的良好支持与换肤功能.为了构建avalon ui,今天起我将投入一部分精力来研究时下最流行的几个CSS框架.它是首当其冲. jquer ...
- plsql中的光标
操作oracle数据库效率最高的语言就是plsql程序,故而把访问数据库的代码写成plsql的执行效率要高于java,c ,c++等代码
- 使用heap profiler进行内存占用分析
最近在项目中用到了google的heap profiler工具来分析内存占用,效果非常显著,因此在这里写一篇博客记录一下使用过程中遇到的一些问题. heap profiler依赖于tcmalloc,所 ...
- sh 脚本
more log.log| awk '{if($1>"15:10:54.851" && length($1)==12){print $0}}'
- 论immutable不可变性
什么叫immutable和mutable?简单来讲,一个immutable的对象一旦被创建好,它的状态将不会改变.反过来,如果一个类的实例是immutable的,那么我们把这个类也称作immutabl ...
- linux系统软件版本升级
在安装完软件之后,在同一层目录生成一个符号链接,并把当前软件的目录映射到这个链接上,后面的操作都只通过这个链接去做,以后升级版本的时候,把最新的软件目录映射到这个链接上就可以了. 如我刚装的apach ...
- k8s启动Pod遇到CrashLoopBackOff的解决方法
1.用kubectl get pod 当看到上面的状态后执行第2步 2.查看pod详情 [root@cc hzb]# kubectl describe pod ceph-mysql-hzb-pod 找 ...