- 浏览: 515440 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
tangyunliang:
大哥你太历害了谢谢
Android基于XMPP Smack Openfire开发IM【四】初步实现两个客户端通信 -
u013015029:
LZ,请问下,在// 添加消息到聊天窗口 , 这里获取Ed ...
Android基于XMPP Smack Openfire开发IM【四】初步实现两个客户端通信 -
endual:
怎么保持会话,我搞不懂啊
Android基于XMPP Smack Openfire开发IM【一】登录openfire服务器 -
donala_zq:
显示:[2013-11-30 11:50:36 - Andro ...
android-----------新浪微博 -
donala_zq:
哥,运行不了啊
android-----------新浪微博
底部菜单栏实现
效果图:
[img]
[/img]
工程结构图:
[img]
[/img]
main.xml:
drawable/home_btn_bg.xml:切换时的效果
string/dimens.xml 尺寸文件:
string/drawables.xml 设置为透明
string/styles.xml 样式文件
主要的代码
效果图:
[img]
[/img]
工程结构图:
[img]
[/img]
main.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"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0"/> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0" android:visibility="gone"/> <RadioGroup android:id="@+id/main_tab" android:background="@drawable/maintab_toolbar_bg" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_gravity="bottom"> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/main_home" android:drawableTop="@drawable/icon_1_n" android:id="@+id/radio_button0" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/main_news" android:drawableTop="@drawable/icon_2_n" android:id="@+id/radio_button1" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/main_my_info" android:drawableTop="@drawable/icon_3_n" android:id="@+id/radio_button2" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/menu_search" android:drawableTop="@drawable/icon_4_n" android:id="@+id/radio_button3" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/more" android:drawableTop="@drawable/icon_5_n" android:id="@+id/radio_button4" style="@style/main_tab_bottom"/> </RadioGroup> </LinearLayout> </TabHost>
drawable/home_btn_bg.xml:切换时的效果
<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_enabled="true" android:state_pressed="false" android:drawable="@drawable/home_btn_bg_s" /> <item android:state_enabled="true" android:state_pressed="true" android:drawable="@drawable/home_btn_bg_s" /> <item android:state_enabled="true" android:state_checked="true" android:drawable="@drawable/home_btn_bg_d" /> <item android:drawable="@drawable/transparent" /> </selector>
string/dimens.xml 尺寸文件:
<?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="bottom_tab_padding_drawable">2.0dip</dimen> <dimen name="bottom_tab_padding_up">5.0dip</dimen> <dimen name="bottom_tab_font_size">10.0dip</dimen> </resources>
string/drawables.xml 设置为透明
<?xml version="1.0" encoding="utf-8"?> <resources> <item type="drawable" name="transparent">#00000000</item> </resources>
string/styles.xml 样式文件
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="main_tab_bottom"> <item name="android:textSize">@dimen/bottom_tab_font_size</item> <item name="android:textColor">#ffffffff</item> <item name="android:ellipsize">marquee</item> <item name="android:gravity">center_horizontal</item> <item name="android:background">@drawable/home_btn_bg</item> <item name="android:paddingTop">@dimen/bottom_tab_padding_up</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:button">@null</item> <item name="android:singleLine">true</item> <item name="android:drawablePadding">@dimen/bottom_tab_padding_drawable</item> <item name="android:layout_weight">1.0</item> </style> </resources>
主要的代码
package com.loulijun.demo2; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.view.Window; import android.widget.RadioGroup; import android.widget.TabHost; import android.widget.RadioGroup.OnCheckedChangeListener; public class MainTabActivity extends TabActivity implements OnCheckedChangeListener{ private RadioGroup mainTab; private TabHost tabhost; private Intent iHome; private Intent iNews; private Intent iInfo; private Intent iSearch; private Intent iMore; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); mainTab=(RadioGroup)findViewById(R.id.main_tab); mainTab.setOnCheckedChangeListener(this); tabhost = getTabHost(); iHome = new Intent(this, HomeActivity.class); tabhost.addTab(tabhost.newTabSpec("iHome") .setIndicator(getResources().getString(R.string.main_home), getResources().getDrawable(R.drawable.icon_1_n)) .setContent(iHome)); iNews = new Intent(this, NewsActivity.class); tabhost.addTab(tabhost.newTabSpec("iNews") .setIndicator(getResources().getString(R.string.main_news), getResources().getDrawable(R.drawable.icon_2_n)) .setContent(iNews)); iInfo = new Intent(this, MyInfoActivity.class); tabhost.addTab(tabhost.newTabSpec("iInfo") .setIndicator(getResources().getString(R.string.main_my_info), getResources().getDrawable(R.drawable.icon_3_n)) .setContent(iInfo)); iSearch = new Intent(this,SearchActivity.class); tabhost.addTab(tabhost.newTabSpec("iSearch") .setIndicator(getResources().getString(R.string.menu_search), getResources().getDrawable(R.drawable.icon_4_n)) .setContent(iSearch)); iMore = new Intent(this, MoreActivity.class); tabhost.addTab(tabhost.newTabSpec("iMore") .setIndicator(getResources().getString(R.string.more), getResources().getDrawable(R.drawable.icon_5_n)) .setContent(iMore)); } @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch(checkedId){ case R.id.radio_button0: this.tabhost.setCurrentTabByTag("iHome"); break; case R.id.radio_button1: this.tabhost.setCurrentTabByTag("iNews"); break; case R.id.radio_button2: this.tabhost.setCurrentTabByTag("iInfo"); break; case R.id.radio_button3: this.tabhost.setCurrentTabByTag("iSearch"); break; case R.id.radio_button4: this.tabhost.setCurrentTabByTag("iMore"); break; } } }
发表评论
-
Android中如何模拟一次点击(touch)事件
2014-05-06 10:41 0在Android中有时需要模拟某一个View的touch事件, ... -
Android程序Crash时的异常上报
2014-04-28 18:15 0http://blog.csdn.net/singwhatiw ... -
android程序中证书签名校验的方法
2014-04-28 17:58 1893android程序中证书签名校验的方法一 2013-02 ... -
MD5理解错了,哎
2014-03-17 14:14 0MD5只对数据加密是无法解密的,也就是说,你把100加密后,就 ... -
Android 获取网络时间
2014-03-12 11:42 2004Android 获取网络时间 在网上看到的最常见的方式有: ... -
SQLite清空表并将自增列归零
2014-03-05 18:02 1458SQLite清空表并将自增列归零 作者:Zhu Yanfeng ... -
Handler小看一下
2013-11-11 16:42 0android handler调用post方法还是阻塞 su ... -
Frame Animation小看一下
2013-10-12 16:30 713Demo运行效果图: 源码: -
动画小学一下
2013-10-12 16:14 686转自: http://www.eoeandroid.com/f ... -
Android 动画之ScaleAnimation应用详解
2013-10-12 15:49 954===============eoeAndroid社区推荐:= ... -
android开发中的一个工具类
2013-06-19 16:04 0package com.wanpu.login.dialog; ... -
android TextView怎么设置个别字体颜色并换行?
2013-06-20 09:25 1628(1)、TextView 设置个别字体颜色 TextView ... -
Android开发之文件下载,状态时显示下载进度,点击自动安装
2013-05-07 15:38 1359在进行软件升级时,需要进行文件下载,在这里实现自定义的文件下载 ... -
android中的状态保存
2013-04-07 14:21 927package com.zzl.call; import ... -
android动画基础:tween动画
2013-04-06 11:21 1176工程结构图: [img] [/img] 四个动画的xml ... -
面试中遇到的几个问题
2013-06-09 11:56 934SAX与DOM之间的区别 SAX ( ... -
Android获取其他包的Context实例,然后调用它的方法,反射!!!
2013-03-25 10:32 1151Android中有Context的概念,想必大家都知道。Con ... -
Android的内存机制和常见泄漏情形
2013-03-06 16:55 749一、 Android的内存机制 Android的程序由Ja ... -
JUnit测试小小demo
2013-03-06 16:37 1076运行效果图: [img] [/img] 项目结构图 ... -
android开发中的异常小工具
2013-03-04 15:53 857package com.zzl.tools; impor ...
相关推荐
Android - 底部菜单架构设计及封装实现 对应下面的文章: http://blog.csdn.net/yzj_work/article/details/6894997
android使用ViewPager实现底部菜单栏和左右滑动效果,加载多个Activity
使用RadioGroup实现的底部导航菜单栏
Android-NavMenu-master一个底部导航栏, 实现了显示未读消息数, 显示红点等效果的封装
让你五分钟就可以接入fragment的底部菜单栏,或者接入fragment+viewpager的底部菜单栏。
Fragment碎片实现底部菜单栏,仿支付宝UI
android 底部菜单实现
用两种不同的方式实现了Android底部菜单栏的效果(也叫Tab选项卡)
使用TabHost实现底部菜单栏,很好用的啊,欢迎下载啊,欢迎指导批评,若是不好的话。个人亲自测试可以的啊。
积攒的资源,TabHost实现底部菜单栏的功能
Fragment+FragmentTabHost实现仿新浪微博底部菜单栏效果(源码)
(1)通过TabWidget实现 (2)隐藏TabWidget,通过RadioGroup和RadioButton实现底部菜单栏
Android 使用RadioGroup 实现底部导航菜单栏。 一、主界面布局的实现: 先来张效果图: 介绍一下总体界面包括的内容:底部五个导航按钮,主界面包括一个FrameLayout用来放五个Fragment。点击底部按钮会对应跳转...
android底部菜单栏实现源码,参考。
Android实现底部菜单栏及切换效果代码
Android 实现底部导航中间菜单凸起效果,不满意不要钱,哈哈 ~
一个纯代码实现的android底部菜单栏,动态加载,简单实用
在Android中实现两种主要的Tab效果:... 仿微信底部菜单;2. 仿今日头条顶部导航条。博客讲解见:https://blog.csdn.net/ahuyangdong/article/details/82493158。github源码:https://github.com/ahuyangdong/TabCustom
android 应用 底部菜单栏的实现LinearLayout