android实现界面底部的tab
2010-04-12 12:42
489 查看
默认的tabhost中的tabwidget是放在顶部的,有时需要将TAB移到底部来,这时需要在XML中做些细微的变动,如下:
我们将tabWidget放到一个relativeLayout中,然后加上这句android:layout_alignParentBottom="true",代码实现如下
这样就可以把tab置于页面底部了,其实跟上次讲的LinearLayout的buttonBar样式有点类似
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabHost android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingBottom="62px"> <AnalogClock android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" /> <Button android:id="@+id/tab2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="A semi-random button" /> </FrameLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_alignParentBottom="true" android:layout_width="fill_parent" android:layout_height="60px" /> </RelativeLayout> </TabHost> </LinearLayout>
我们将tabWidget放到一个relativeLayout中,然后加上这句android:layout_alignParentBottom="true",代码实现如下
public class TabTest2 extends Activity { public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.tabtest2); TabHost tabs=(TabHost)findViewById(R.id.tabhost); tabs.setup(); TabHost.TabSpec spec=tabs.newTabSpec("tag1"); spec.setContent(R.id.tab1); spec.setIndicator("Clock"); tabs.addTab(spec); spec=tabs.newTabSpec("tag2"); spec.setContent(R.id.tab2); spec.setIndicator("Button"); tabs.addTab(spec); tabs.setCurrentTab(0); } }
这样就可以把tab置于页面底部了,其实跟上次讲的LinearLayout的buttonBar样式有点类似
相关文章推荐
- android实现界面底部的tab
- Android典型界面设计——FragmentTabHost+Fragment实现底部tab切换
- [Android] 使用 Fragment 实现底部 Tab 切换界面
- Android典型界面设计——FragmentTabHost+Fragment实现底部tab切换
- Android典型界面设计——FragmentTabHost+Fragment实现底部tab切换
- Android 用 TabLayout + ViewPager + Fragment 实现顶部、底部导航栏
- Android解析自定义属性的XML实现底部导航栏TabSelectedView,实现灵活的配置扩展
- 【Android界面实现】使用PagerSlidingTabStrip实现滑动标签同步的ViewPager效果
- android 中使用TabHost控件实现微信界面的底部菜单效果
- Android三种实现Tab界面效果的方法,ViewPager + Fragment
- 【Android 新浪微博】--底部Tab的实现
- Android典型界面设计(8) ——ViewPager+PagerSlidingTabStrip实现双导航
- Android UI开发第三十九篇——Tab界面实现汇总及比较
- Android 底部菜单栏Tab功能的几种实现方式
- Android Tablayout 结合ViewPager实现滑动界面
- Android UI开发第三十九篇——Tab界面实现汇总及比较
- Android开发教程:底部Tab的两种实现方式
- 【Android进阶学习】底部Tab的两种实现方式
- android底部标签页的tab实现
- Android 底部TabActivity(0)——开篇(界面分析|系列文章文件夹)