- 浏览: 416755 次
- 性别:
- 来自: 上海
-
文章分类
- 全部博客 (398)
- 随笔 (3)
- java (44)
- android (129)
- html + css (18)
- php (35)
- linux (2)
- html5技术/游戏 (3)
- 其他 (30)
- MAC (2)
- IOS (11)
- mongoDB (0)
- js + jquery (29)
- SQL (5)
- ecshop (2)
- jsp (1)
- mybatis (1)
- 推荐 (0)
- 网络推广 (1)
- jquery mobiles (7)
- Sencha Tcouch (11)
- case (2)
- joomla (1)
- cocos2d (1)
- AndEngine (1)
- 错误异常报错 (1)
- 第三方&二次开发 (5)
- cordova (5)
- swift (81)
- mysql (1)
- zepto (2)
- 常用代码 (1)
- 健康 (0)
最新评论
-
wu1238:
2c2ab98030fc767cf89051f369a97c5 ...
Swift -> UILable 设置内边距 UIEdgeInsets , UITextField 设置内边距
tab.xml 布局
<?xml version="1.0" encoding="utf-8"?> <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"/> </RelativeLayout> </TabHost>
----- 其中 解决 TAB层 遮住 了后面 的 主层的解决办法 的 布局
<?xml version="1.0" encoding="utf-8"?> <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_weight="10" android:layout_height="fill_parent"/> </LinearLayout> </TabHost>
tab_list.xml
<?xml version="1.0" encoding="UTF-8"?> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="3dip" android:paddingBottom="3dip" android:background="#393C42" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/tab_imageview_icon" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="fitCenter" /> <TextView android:id="@+id/tab_textview_title" android:textColor="#FFFFFF" android:textSize="10dip" android:ellipsize="marquee" android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:marqueeRepeatLimit="1" /> </LinearLayout>
主activity
package tab.mft; import cfg.mft.CfgIndex; import login.mft.LoginAddSensor; import login.mft.LoginIndexActivity; import remote2.mft.R; import android.app.TabActivity; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.TabHost; import android.widget.TabHost.OnTabChangeListener; import android.widget.TextView; public class TabIndex extends TabActivity{ private TabHost tabHost; private static final String SYS = "系统"; private static final String SERVERS = "服务"; private static final String MORE = "更多"; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.tab); tabHost=getTabHost(); final View view=View.inflate(TabIndex.this, R.layout.tab_list, null); view.setBackgroundColor(Color.rgb(33,36,41)); //默认第一个点亮 ((ImageView)view.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_home_sel); //默认第一个点亮 ((TextView)view.findViewById(R.id.tab_textview_title)).setText(SYS); TabHost.TabSpec tabSpec=tabHost.newTabSpec(SYS).setIndicator(view).setContent(new Intent(TabIndex.this, LoginIndexActivity.class)); tabHost.addTab(tabSpec); final View view1=View.inflate(TabIndex.this, R.layout.tab_list, null); ((ImageView)view1.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_selfinfo_nor); ((TextView)view1.findViewById(R.id.tab_textview_title)).setText(SERVERS); TabHost.TabSpec tabSpec1=tabHost.newTabSpec(SERVERS).setIndicator(view1).setContent(new Intent(TabIndex.this, LoginAddSensor.class)); tabHost.addTab(tabSpec1); final View view2=View.inflate(TabIndex.this, R.layout.tab_list, null); ((ImageView)view2.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_more_nor); ((TextView)view2.findViewById(R.id.tab_textview_title)).setText(MORE); TabHost.TabSpec tabSpec2=tabHost.newTabSpec(MORE).setIndicator(view2).setContent(new Intent(TabIndex.this, LoginAddSensor.class)); tabHost.addTab(tabSpec2); tabHost.setCurrentTab(0); //设置切换监听 tabHost.setOnTabChangedListener(new OnTabChangeListener(){ public void onTabChanged(String tabId){ ((ImageView)view.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_home_nor); view.setBackgroundColor(Color.rgb(57,60,66)); ((ImageView)view1.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_selfinfo_nor); view1.setBackgroundColor(Color.rgb(57,60,66)); ((ImageView)view2.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_more_nor); view2.setBackgroundColor(Color.rgb(57,60,66)); if(tabId.equals(SYS)){ ((ImageView)view.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_home_sel); view.setBackgroundColor(Color.rgb(33,36,41)); } if(tabId.equals(SERVERS)){ ((ImageView)view1.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_selfinfo_sel); view1.setBackgroundColor(Color.rgb(33,36,41)); } if(tabId.equals(MORE)){ ((ImageView)view2.findViewById(R.id.tab_imageview_icon)).setImageResource(R.drawable.icon_more_sel); view2.setBackgroundColor(Color.rgb(33,36,41)); } } }); } }
发表评论
-
android -> ImageButton 内部图片 padding
2020-04-09 12:00 490先给 ImageButton 设置属性 andr ... -
android -> 设置 全局 字体样式
2017-05-05 11:11 778首页在AndroidManifest.xml中 ap ... -
android -> 背景background - shape的使用
2017-05-04 12:09 953shape用于设定形状,可以在selector, ... -
android -> 只保留一边 的 边框 border
2017-05-03 09:05 1110设置background <layer-li ... -
android -> 在布局中动态添加view的两种方法
2017-04-29 19:48 1036转自 : http://b ... -
android -> 修改 version 版本
2017-03-28 15:33 450除了在 manifest.xml 里面 <?xml ... -
android -> viewPaer 页面滑动
2017-03-27 17:23 590MainActivity.java public ... -
android -> 获取系统输入法列表/已勾选/默认
2017-03-26 13:02 1243参考: http://www.aichengxu. ... -
android -> android 一个 textview 设置不同的字体大小和颜色
2017-03-24 00:05 931参考: http://blog.csdn.net/fengy ... -
android -> 查看 签名 的 信息 包括 有效期
2017-03-23 11:27 1094C:\Windows\system32>D ... -
android -> 父控件 遍历 子 控件
2017-03-21 21:03 771布局文件: <LinearLayout an ... -
android -> 动画类( Animation)
2017-03-19 11:01 568参考: https://my.oschina.net/u/ ... -
android -> TextView setTextSize(int unit, float size) -- px,sp,dip
2017-03-18 23:35 1113TextView setTextSize(int unit, ... -
android -> canvas学习3 (跟随手势画直线)
2017-03-10 17:17 966DiyView.java package com ... -
android -> canvas学习2(动态画图)
2017-03-10 16:31 638关键字 invalidate() 重新执行onDra ... -
android -> canvas学习1
2017-03-10 14:39 532参考: http://blog.csdn.net/lee5 ... -
android -> 九宫格 划直线解锁
2017-03-09 22:53 477来自 : http://blog.csdn.net/ ... -
android -> 按钮 圆角 & 边框 & 渐变
2017-02-14 16:32 955参考: http://blog.csdn.net/l ... -
android -> 资源文件 反编译
2017-02-14 15:30 454官方网站 : https://ibotpeaches ... -
android -> 按钮双击
2017-02-12 11:48 506long space_last_click_time; ...
相关推荐
在Android开发中,TabHost是一个非常重要的组件,它允许开发者创建多标签的界面,类似于浏览器中的标签页。本文将深入探讨如何自定义TabHost来实现类似新浪微博的效果,从而提升用户体验和应用的交互性。 首先,...
总结,"仿新浪微博TabHost菜单"的实现涉及Android的布局管理、Intent机制、自定义视图以及事件监听等多个方面。开发者需要熟练掌握这些基础知识,才能创建出富有个性和用户体验良好的App界面。通过这个特效集锦系列...
我们将探讨如何利用Android的TabHost组件以及相关的布局技术来创建类似的用户界面。 首先,让我们了解TabHost组件。TabHost是Android提供的一个容器,它允许你在同一个视图中显示多个Tab(标签页)。每个Tab都可以...
在Android应用开发中,TabHost是一个非常常见的组件,它用于创建多标签的界面,让用户能够通过不同的标签页浏览和切换不同的功能。美化TabHost是为了提供更好的用户体验,使其更符合当前主流设计趋势,如新浪微博...
在Android程序开发中,自定义TabHost和TabWidget的样式是一项常见的任务,用于创建类似京东商城和新浪微博底部菜单栏的效果。TabHost和TabWidget是Android SDK提供的组件,用于实现多标签界面,让用户能够轻松地在...
`FragmentTabHost`是Android SDK提供的一种用于在Tab布局中管理`Fragment`的类,它继承自`TabHost`,并且对`TabHost`进行了扩展,使得我们可以在每个标签页中放入`Fragment`,而不是传统的`View`。这种方式更有利于...
Android RecycleView+任意头尾布局+拖拽换位+拖拽删除demo Android sql练习合集 Android 仿12306 Android 优秀计步器 Android 体重计算源码 Android 使用Gallery_tabhost实现标签效果图源码 Android 例子源码根据CPU...
开发者需要将各个小部件添加到TabHost中,并为每个标签设置相应的活动或布局。TabHost通过`setup()`方法初始化,然后使用`addTab()`方法为每个标签添加对应的显示内容。在设置完所有标签后,通过`setTabWidget()`和`...
要创建一个`TabHost`,首先需要在XML布局文件中声明一个`TabHost`元素,并设置其id为`android:id/tabhost`。接着,在代码中通过`TabHost`的`setup()`方法初始化它,并添加所需的选项卡。 2. **定义TabWidget** `...
综上所述,`TabHostDemo`是一个演示如何使用`FragmentTabHost`构建多标签界面的实例,它结合了`Fragment`的灵活性和`TabHost`的便利性,是Android应用中实现类似微博主界面功能的常见解决方案。通过深入学习和实践这...