`

2011.09.14(2)——— android tabhost位于底部

阅读更多
2011.09.14(2)——— android tabhost位于底部
参考:http://blog.csdn.net/tt_iceberg/article/details/6430701
http://blog.csdn.net/roadog2006/article/details/5475549

从网上找了一圈 大致有两种方法

方法一:

<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">  
      <FrameLayout android:id="@android:id/tabcontent"  
      android:layout_width="fill_parent"   
      android:layout_height="match_parent"  
      android:layout_weight="1" >   
      </FrameLayout>  
      <TabWidget android:id="@android:id/tabs"  
      android:layout_width="fill_parent"   
      android:layout_height="wrap_content" />  
    </LinearLayout>  
</TabHost>


1、tabcontent和tabs交换位置
2、tabcontent的android:layout_weight="1"


方法二:

<?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">
		</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>



1、tabcontent和tabs交换位置
2、将tabcontent放到一个relativeLayout中,然后加上这句android:layout_alignParentBottom="true"






  • 大小: 136.8 KB
分享到:
评论

相关推荐

    Android源码——android tabhost --android UI源码.zip

    这个压缩包"Android源码——android tabhost --android UI源码.zip"可能包含了一些示例代码,图片资源以及关于如何使用TabHost的解释。 首先,我们来深入理解TabHost的工作原理。TabHost是一个容器,它管理着多个...

    安卓Android源码——嵌套TabHost示例.zip

    `TabSpec`可以通过`TabHost.newTabSpec()`创建,然后使用`setIndicator()`设置标签的显示文本,用`setContent()`设置点击标签后要显示的活动或视图。 对于嵌套的`TabHost`,我们可以在子活动中再次创建一个`TabHost...

    android Tabhost 实现底部菜单效果

    TabSpec tab2 = tabHost.newTabSpec("标签2"); tab2.setIndicator("标签2", getResources().getDrawable(R.drawable.tab_icon_2)); tab2.setContent(new Intent(this, Tab2Activity.class)); // 添加更多标签... ...

    android TabHost 底部显示

    TabSpec tab2Spec = tabHost.newTabSpec("tab2"); tab2Spec.setIndicator("Tab 2") .setContent(new Intent(this, Tab2Activity.class)); tabHost.addTab(tab1Spec); tabHost.addTab(tab2Spec); ``` 这里,Tab1...

    安卓Android源码——ViewPager和Tabhost结合,可滑动的tabhost.rar

    这个压缩包"安卓Android源码——ViewPager和Tabhost结合,可滑动的tabhost.rar"提供了将两者结合使用的示例代码,帮助开发者创建一个可以滑动的`TabHost`,增强用户体验。 `ViewPager` 是Android SDK中的一个强大...

    安卓Android源码——ViewPager和Tabhost结合,可滑动的tabhost.zip

    在某些场景下,开发者可能希望将这两者结合,实现可滑动的标签页,这正是“安卓Android源码——ViewPager和Tabhost结合,可滑动的tabhost.zip”所展示的内容。 `ViewPager` 是Android Support Library中的一个组件...

    Android-TabHost.rar_android_android tabhost_tabhost_tabhost andr

    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if ("tab1".equals(tabId)) { // 处理标签1被选中的逻辑 } else if ("tab2"....

    android TabHost简单使用

    TabSpec tab2Spec = tabHost.newTabSpec("tab2"); tab2Spec.setIndicator("选项卡2"); Intent intent2 = new Intent(this, Tab2Activity.class); tab2Spec.setContent(intent2); tabHost.addTab(tab2Spec); /...

    Android TabHost嵌套示例.rar

    Android TabHost嵌套示例,像电脑端一样在屏幕上显示上下嵌套的TAB效果,单击后切换内容,在内容页上又重新显示二级的TAB,实现嵌套,如示例图所示,注意:对于TabHost、布局文件中必须包含:  TabHost、TabWidget ...

    android Tabhost使用Demo

    TabSpec spec2 = tabHost.newTabSpec("tab2"); spec2.setIndicator("Tab 2", getResources().getDrawable(R.drawable.ic_tab2)); spec2.setContent(new Intent(this, Tab2Activity.class)); tabHost.addTab(spec...

    安卓Android源码——tabhost--UI源码.zip

    TabSpec spec = tabHost.newTabSpec("标签名").setIndicator("标签文本").setContent(intent); ``` 4. 将标签添加到TabHost:将创建好的TabSpec添加到TabHost中。 ```java tabHost.addTab(spec); ``` 5. 设置默认...

    Android 嵌套TabHost示例

    2. 设置布局:调用`tabHost.setup();`初始化TabHost。 3. 添加标签:使用`TabSpec tabSpec = tabHost.newTabSpec("tag");`创建一个标签规格,然后设置标签文字、图标和关联的Intent。 4. 添加内容:通过`tabSpec....

    Androidtabhost--AndroidUI源码.zip

    TabSpec tab2 = tabHost.newTabSpec("Tab2"); tab2.setIndicator("Tab2"); Intent intent2 = new Intent(this, Tab2Activity.class); tab2.setContent(intent2); tabHost.addTab(tab1); tabHost.addTab(tab2)...

    Android tabhost控件

    TabSpec tabSpec2 = tabHost.newTabSpec("Tab 2"); tabSpec2.setIndicator("标签2"); tabSpec2.setContent(R.id.tab2_content); // 将TabSpec添加到TabHost tabHost.addTab(tabSpec1); tabHost.addTab(tabSpec2); `...

    新浪微博布局学习——妙用TabHost.zip

    本资料“新浪微博布局学习——妙用TabHost.zip”显然是针对如何在Android应用中巧妙运用TabHost来构建类似新浪微博的多标签布局进行的讲解。 TabHost是Android SDK提供的一个类,它的主要功能是管理一组TabWidget...

    Android25闹钟项目——tabhost的使用,刷新时间

    TabSpec tab2 = tabHost.newTabSpec("标签2"); tab2.setIndicator("标签2标题") .setContent(new Intent(this, Tab2Activity.class)); tabHost.addTab(tab2); ``` 这里,`TabSpec`用于定义每个标签的属性,包括标签...

    (框架)Android例子源码——tabhost+activity+slidingMenu仿新浪微博布局.zip

    该压缩包文件是一个Android开发的学习资源,主要展示了如何使用TabHost、Activity以及SlidingMenu来构建一个类似新浪微博的用户界面。下面将详细解释这些技术及其在Android应用开发中的作用。 **TabHost**: TabHost...

    android TabHost自定义选项卡

    TabSpec tab2 = tabHost.newTabSpec("tab2"); tab2.setIndicator("标签2"); tab2.setContent(new Intent(this, Tab2Activity.class)); // 将TabSpec添加到TabHost tabHost.addTab(tab1); tabHost.addTab(tab2); ```...

Global site tag (gtag.js) - Google Analytics